diff --git a/docs/configuration/index.md b/docs/configuration/index.md index 519abf5f6f6..ea15380260e 100644 --- a/docs/configuration/index.md +++ b/docs/configuration/index.md @@ -422,9 +422,14 @@ There are several emitters available: ##### Logging Emitter Module -|Property|Description|Default| -|--------|-----------|-------| -|`druid.emitter.logging.loggerClass`|Choices: HttpPostEmitter, LoggingEmitter, NoopServiceEmitter, ServiceEmitter. The class used for logging.|LoggingEmitter| +The use this emitter module, set `druid.emitter=logging`. The `logging` emitter uses a Log4j2 logger named +`druid.emitter.logging.loggerClass` to emit events. Each event is logged as a single `json` object with a +[Marker](https://logging.apache.org/log4j/2.x/manual/markers.html) as the feed of the event. Users may wish to edit the +log4j config to route these logs to different sources based on the feed of the event. + +|Property|Description| Default | +|--------|-----------|-----------------------------------------------------| +|`druid.emitter.logging.loggerClass`|The class used for logging.|`org.apache.druid.java.util.emitter.core.LoggingEmitter`| |`druid.emitter.logging.logLevel`|Choices: debug, info, warn, error. The log level at which message are logged.|info| ##### HTTP Emitter Module diff --git a/docs/configuration/logging.md b/docs/configuration/logging.md index 20ac6cae487..2c598e3f097 100644 --- a/docs/configuration/logging.md +++ b/docs/configuration/logging.md @@ -45,14 +45,14 @@ The following example log4j2.xml is based upon the micro quickstart: - + - + @@ -157,7 +157,7 @@ The following example shows a `log4j2.xml` that configures some of the more chat - + diff --git a/examples/conf/druid/auto/_common/log4j2.xml b/examples/conf/druid/auto/_common/log4j2.xml index 66dc13da4c5..0bda2f6968f 100644 --- a/examples/conf/druid/auto/_common/log4j2.xml +++ b/examples/conf/druid/auto/_common/log4j2.xml @@ -26,14 +26,14 @@ - + - + diff --git a/examples/conf/druid/cluster/_common/log4j2.xml b/examples/conf/druid/cluster/_common/log4j2.xml index f55b70070c2..eb24a2a8940 100644 --- a/examples/conf/druid/cluster/_common/log4j2.xml +++ b/examples/conf/druid/cluster/_common/log4j2.xml @@ -26,14 +26,14 @@ - + - + diff --git a/examples/conf/druid/single-server/large/_common/log4j2.xml b/examples/conf/druid/single-server/large/_common/log4j2.xml index 66dc13da4c5..0bda2f6968f 100644 --- a/examples/conf/druid/single-server/large/_common/log4j2.xml +++ b/examples/conf/druid/single-server/large/_common/log4j2.xml @@ -26,14 +26,14 @@ - + - + diff --git a/examples/conf/druid/single-server/medium/_common/log4j2.xml b/examples/conf/druid/single-server/medium/_common/log4j2.xml index 66dc13da4c5..0bda2f6968f 100644 --- a/examples/conf/druid/single-server/medium/_common/log4j2.xml +++ b/examples/conf/druid/single-server/medium/_common/log4j2.xml @@ -26,14 +26,14 @@ - + - + diff --git a/examples/conf/druid/single-server/micro-quickstart/_common/log4j2.xml b/examples/conf/druid/single-server/micro-quickstart/_common/log4j2.xml index 66dc13da4c5..0bda2f6968f 100644 --- a/examples/conf/druid/single-server/micro-quickstart/_common/log4j2.xml +++ b/examples/conf/druid/single-server/micro-quickstart/_common/log4j2.xml @@ -26,14 +26,14 @@ - + - + diff --git a/examples/conf/druid/single-server/nano-quickstart/_common/log4j2.xml b/examples/conf/druid/single-server/nano-quickstart/_common/log4j2.xml index 66dc13da4c5..0bda2f6968f 100644 --- a/examples/conf/druid/single-server/nano-quickstart/_common/log4j2.xml +++ b/examples/conf/druid/single-server/nano-quickstart/_common/log4j2.xml @@ -26,14 +26,14 @@ - + - + diff --git a/examples/conf/druid/single-server/small/_common/log4j2.xml b/examples/conf/druid/single-server/small/_common/log4j2.xml index 66dc13da4c5..0bda2f6968f 100644 --- a/examples/conf/druid/single-server/small/_common/log4j2.xml +++ b/examples/conf/druid/single-server/small/_common/log4j2.xml @@ -26,14 +26,14 @@ - + - + diff --git a/examples/conf/druid/single-server/xlarge/_common/log4j2.xml b/examples/conf/druid/single-server/xlarge/_common/log4j2.xml index 66dc13da4c5..0bda2f6968f 100644 --- a/examples/conf/druid/single-server/xlarge/_common/log4j2.xml +++ b/examples/conf/druid/single-server/xlarge/_common/log4j2.xml @@ -26,14 +26,14 @@ - + - + diff --git a/extensions-core/azure-extensions/pom.xml b/extensions-core/azure-extensions/pom.xml index a6ce2c7a1da..aa87fc353cc 100644 --- a/extensions-core/azure-extensions/pom.xml +++ b/extensions-core/azure-extensions/pom.xml @@ -159,7 +159,6 @@ org.jacoco jacoco-maven-plugin - 0.8.4 diff --git a/extensions-core/hdfs-storage/pom.xml b/extensions-core/hdfs-storage/pom.xml index 89494185ead..37a2a813bb7 100644 --- a/extensions-core/hdfs-storage/pom.xml +++ b/extensions-core/hdfs-storage/pom.xml @@ -465,6 +465,11 @@ 1.2.17 test + + org.slf4j + slf4j-api + provided + diff --git a/extensions-core/kubernetes-extensions/pom.xml b/extensions-core/kubernetes-extensions/pom.xml index e1190900e73..7e3ba252b9c 100644 --- a/extensions-core/kubernetes-extensions/pom.xml +++ b/extensions-core/kubernetes-extensions/pom.xml @@ -143,7 +143,6 @@ org.jacoco jacoco-maven-plugin - 0.8.5 diff --git a/indexing-service/pom.xml b/indexing-service/pom.xml index 82603e83a20..fbba561c6ad 100644 --- a/indexing-service/pom.xml +++ b/indexing-service/pom.xml @@ -369,7 +369,6 @@ org.jacoco jacoco-maven-plugin - ${jacoco.version} + org/apache/druid/java/util/emitter/core/LoggingEmitter.class + + org/apache/druid/java/util/common/logger/Logger.class + + + diff --git a/processing/src/main/java/org/apache/druid/java/util/common/logger/Logger.java b/processing/src/main/java/org/apache/druid/java/util/common/logger/Logger.java index 64271add16e..3872c2cf768 100644 --- a/processing/src/main/java/org/apache/druid/java/util/common/logger/Logger.java +++ b/processing/src/main/java/org/apache/druid/java/util/common/logger/Logger.java @@ -25,6 +25,7 @@ import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.timeline.DataSegment; import org.apache.druid.timeline.SegmentId; import org.slf4j.LoggerFactory; +import org.slf4j.Marker; import javax.annotation.Nullable; import java.util.Collection; @@ -86,6 +87,13 @@ public class Logger } } + public void trace(Marker marker, String message, Object... formatArgs) + { + if (log.isTraceEnabled()) { + log.trace(marker, StringUtils.nonStrictFormat(message, formatArgs)); + } + } + public void debug(String message, Object... formatArgs) { if (log.isDebugEnabled()) { @@ -93,6 +101,12 @@ public class Logger } } + public void debug(Marker marker, String message, Object... formatArgs) + { + if (log.isDebugEnabled()) { + log.debug(marker, StringUtils.nonStrictFormat(message, formatArgs)); + } + } public void debug(Throwable t, String message, Object... formatArgs) { if (log.isDebugEnabled()) { @@ -107,6 +121,13 @@ public class Logger } } + public void info(Marker marker, String message, Object... formatArgs) + { + if (log.isInfoEnabled()) { + log.info(marker, StringUtils.nonStrictFormat(message, formatArgs)); + } + } + public void info(Throwable t, String message, Object... formatArgs) { if (log.isInfoEnabled()) { @@ -131,6 +152,11 @@ public class Logger log.warn(StringUtils.nonStrictFormat(message, formatArgs)); } + public void warn(Marker marker, String message, Object... formatArgs) + { + log.warn(marker, StringUtils.nonStrictFormat(message, formatArgs)); + } + public void warn(Throwable t, String message, Object... formatArgs) { logException(log::warn, t, StringUtils.nonStrictFormat(message, formatArgs)); @@ -141,6 +167,11 @@ public class Logger log.error(StringUtils.nonStrictFormat(message, formatArgs)); } + public void error(Marker marker, String message, Object... formatArgs) + { + log.error(marker, StringUtils.nonStrictFormat(message, formatArgs)); + } + /** * Protect against assuming slf4j convention. use `error(Throwable t, String message, Object... formatArgs)` instead * diff --git a/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitter.java b/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitter.java index f3d4edf0ad9..afc8e07e2c2 100644 --- a/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitter.java +++ b/processing/src/main/java/org/apache/druid/java/util/emitter/core/LoggingEmitter.java @@ -27,6 +27,7 @@ import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.lifecycle.LifecycleStart; import org.apache.druid.java.util.common.lifecycle.LifecycleStop; import org.apache.druid.java.util.common.logger.Logger; +import org.slf4j.MarkerFactory; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicBoolean; @@ -98,24 +99,24 @@ public class LoggingEmitter implements Emitter switch (level) { case TRACE: if (log.isTraceEnabled()) { - log.trace(jsonMapper.writeValueAsString(event)); + log.trace(MarkerFactory.getMarker(event.getFeed()), jsonMapper.writeValueAsString(event)); } break; case DEBUG: if (log.isDebugEnabled()) { - log.debug(jsonMapper.writeValueAsString(event)); + log.debug(MarkerFactory.getMarker(event.getFeed()), jsonMapper.writeValueAsString(event)); } break; case INFO: if (log.isInfoEnabled()) { - log.info(jsonMapper.writeValueAsString(event)); + log.info(MarkerFactory.getMarker(event.getFeed()), jsonMapper.writeValueAsString(event)); } break; case WARN: - log.warn(jsonMapper.writeValueAsString(event)); + log.warn(MarkerFactory.getMarker(event.getFeed()), jsonMapper.writeValueAsString(event)); break; case ERROR: - log.error(jsonMapper.writeValueAsString(event)); + log.error(MarkerFactory.getMarker(event.getFeed()), jsonMapper.writeValueAsString(event)); break; } } diff --git a/server/pom.xml b/server/pom.xml index 71056fee5d7..d83b550db6d 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -436,7 +436,6 @@ org.jacoco jacoco-maven-plugin - ${jacoco.version}