diff --git a/jetty-maven-plugin/src/it/javax-annotation-api/pom.xml b/jetty-maven-plugin/src/it/javax-annotation-api/pom.xml
index fc1dfce43cfd..2b4ffb1c5645 100644
--- a/jetty-maven-plugin/src/it/javax-annotation-api/pom.xml
+++ b/jetty-maven-plugin/src/it/javax-annotation-api/pom.xml
@@ -45,7 +45,7 @@
org.apache.logging.log4j
- log4j-slf4j18-impl
+ slf4j-impl
@log4j2.version@
diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java
index d36070394f98..c3886e196b9c 100644
--- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java
+++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLogger.java
@@ -21,10 +21,11 @@
import java.util.Objects;
import org.slf4j.Logger;
+import org.slf4j.Marker;
import org.slf4j.event.Level;
-import org.slf4j.helpers.MarkerIgnoringBase;
+import org.slf4j.spi.LocationAwareLogger;
-public class JettyLogger extends MarkerIgnoringBase implements Logger
+public class JettyLogger implements LocationAwareLogger, Logger
{
/**
* The Level to set if you want this logger to be "OFF"
@@ -92,6 +93,42 @@ public void debug(String msg, Throwable throwable)
}
}
+ @Override
+ public boolean isDebugEnabled(Marker marker)
+ {
+ return isDebugEnabled();
+ }
+
+ @Override
+ public void debug(Marker marker, String msg)
+ {
+ debug(msg);
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object arg)
+ {
+ debug(format, arg);
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object arg1, Object arg2)
+ {
+ debug(format, arg1, arg2);
+ }
+
+ @Override
+ public void debug(Marker marker, String format, Object... arguments)
+ {
+ debug(format, arguments);
+ }
+
+ @Override
+ public void debug(Marker marker, String msg, Throwable t)
+ {
+ debug(msg, t);
+ }
+
@Override
public void error(String msg)
{
@@ -137,11 +174,56 @@ public void error(String msg, Throwable throwable)
}
}
+ @Override
+ public boolean isErrorEnabled(Marker marker)
+ {
+ return isErrorEnabled();
+ }
+
+ @Override
+ public void error(Marker marker, String msg)
+ {
+ error(msg);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object arg)
+ {
+ error(format, arg);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object arg1, Object arg2)
+ {
+ error(format, arg1, arg2);
+ }
+
+ @Override
+ public void error(Marker marker, String format, Object... arguments)
+ {
+ error(format, arguments);
+ }
+
+ @Override
+ public void error(Marker marker, String msg, Throwable t)
+ {
+ error(msg, t);
+ }
+
public JettyAppender getAppender()
{
return appender;
}
+ @Override
+ public void log(Marker marker, String fqcn, int levelInt, String message, Object[] argArray, Throwable throwable)
+ {
+ if (this.level <= levelInt)
+ {
+ getAppender().emit(asEvent(intToLevel(levelInt), message, throwable, argArray));
+ }
+ }
+
public void setAppender(JettyAppender appender)
{
this.appender = appender;
@@ -169,8 +251,7 @@ public void setLevel(int lvlInt)
// apply setLevel to children too.
JettyLoggerFactory jettyLoggerFactory = JettyLoggerFactory.getLoggerFactory();
- jettyLoggerFactory.walkChildLoggers(this.getName(),
- (logger) -> logger.setLevel(lvlInt));
+ jettyLoggerFactory.walkChildLoggers(this.getName(), (logger) -> logger.setLevel(lvlInt));
}
@Override
@@ -224,6 +305,42 @@ public void info(String msg, Throwable throwable)
}
}
+ @Override
+ public boolean isInfoEnabled(Marker marker)
+ {
+ return isInfoEnabled();
+ }
+
+ @Override
+ public void info(Marker marker, String msg)
+ {
+ info(msg);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object arg)
+ {
+ info(format, arg);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object arg1, Object arg2)
+ {
+ info(format, arg1, arg2);
+ }
+
+ @Override
+ public void info(Marker marker, String format, Object... arguments)
+ {
+ info(format, arguments);
+ }
+
+ @Override
+ public void info(Marker marker, String msg, Throwable t)
+ {
+ info(msg, t);
+ }
+
@Override
public boolean isDebugEnabled()
{
@@ -309,6 +426,42 @@ public void trace(String msg, Throwable throwable)
}
}
+ @Override
+ public boolean isTraceEnabled(Marker marker)
+ {
+ return isTraceEnabled();
+ }
+
+ @Override
+ public void trace(Marker marker, String msg)
+ {
+ trace(msg);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object arg)
+ {
+ trace(format, arg);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object arg1, Object arg2)
+ {
+ trace(format, arg1, arg2);
+ }
+
+ @Override
+ public void trace(Marker marker, String format, Object... argArray)
+ {
+ trace(format, argArray);
+ }
+
+ @Override
+ public void trace(Marker marker, String msg, Throwable t)
+ {
+ trace(msg, t);
+ }
+
@Override
public void warn(String msg)
{
@@ -354,6 +507,59 @@ public void warn(String msg, Throwable throwable)
}
}
+ @Override
+ public boolean isWarnEnabled(Marker marker)
+ {
+ return isWarnEnabled();
+ }
+
+ @Override
+ public void warn(Marker marker, String msg)
+ {
+ warn(msg);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object arg)
+ {
+ warn(format, arg);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object arg1, Object arg2)
+ {
+ warn(format, arg1, arg2);
+ }
+
+ @Override
+ public void warn(Marker marker, String format, Object... arguments)
+ {
+ warn(format, arguments);
+ }
+
+ @Override
+ public void warn(Marker marker, String msg, Throwable t)
+ {
+ warn(msg, t);
+ }
+
+ public static Level intToLevel(int level)
+ {
+ if (level >= JettyLogger.OFF)
+ return Level.ERROR;
+ if (level >= Level.ERROR.toInt())
+ return Level.ERROR;
+ if (level >= Level.WARN.toInt())
+ return Level.WARN;
+ if (level >= Level.INFO.toInt())
+ return Level.INFO;
+ if (level >= Level.DEBUG.toInt())
+ return Level.DEBUG;
+ if (level >= Level.TRACE.toInt())
+ return Level.TRACE;
+ return Level.TRACE; // everything else
+ }
+
public static String levelToString(int level)
{
if (level >= JettyLogger.OFF)
@@ -371,6 +577,7 @@ public static String levelToString(int level)
return "OFF"; // everything else
}
+ @SuppressWarnings("StringBufferReplaceableByString")
@Override
public String toString()
{
@@ -416,6 +623,13 @@ private JettyLoggingEvent asEvent(Level level, String format, Object arg1, Objec
}
}
+ private JettyLoggingEvent asEvent(Level level, String format, Throwable cause, Object... args)
+ {
+ String threadName = Thread.currentThread().getName();
+ long timestamp = System.currentTimeMillis();
+ return new JettyLoggingEvent(this, level, threadName, timestamp, format, cause, args);
+ }
+
private JettyLoggingEvent asEvent(Level level, String format, Object... args)
{
String threadName = Thread.currentThread().getName();
diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java
index 7e90908d7d46..c7a9fe8aa333 100644
--- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java
+++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerFactory.java
@@ -172,7 +172,6 @@ public JettyLogger getRootLogger()
private JettyLogger createLogger(String name)
{
- // TODO: if SOURCE property is configured, return a org.slf4j.spi.LocationAwareLogger wrapper?
// or is that handled by slf4j itself?
JettyLogger jettyLogger = new JettyLogger(name);
jettyLogger.setLevel(this.configuration.getLevel(name));
diff --git a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingEvent.java b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingEvent.java
index e472bcbb603e..324baa2b1fd0 100644
--- a/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingEvent.java
+++ b/jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggingEvent.java
@@ -18,7 +18,10 @@
package org.eclipse.jetty.logging;
+import java.util.List;
+
import org.slf4j.Marker;
+import org.slf4j.event.KeyValuePair;
import org.slf4j.event.Level;
import org.slf4j.event.LoggingEvent;
@@ -63,12 +66,6 @@ public Level getLevel()
return this.level;
}
- @Override
- public Marker getMarker()
- {
- return null;
- }
-
@Override
public String getLoggerName()
{
@@ -81,6 +78,12 @@ public String getMessage()
return this.message;
}
+ @Override
+ public List