Logging

Apache Druid processes will emit logs that are useful for debugging to the console. Druid processes also emit periodic metrics about their state. For more about metrics, see Configuration. Metric logs are printed to the console by default, and can be disabled with -Ddruid.emitter.logging.logLevel=debug.

Druid uses log4j2 for logging. Logging can be configured with a log4j2.xml file. Add the path to the directory containing the log4j2.xml file (e.g. the _common/ dir) to your classpath if you want to override default Druid log configuration. Note that this directory should be earlier in the classpath than the druid jars. The easiest way to do this is to prefix the classpath with the config dir.

To enable java logging to go through log4j2, set the -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager server parameter.

An example log4j2.xml ships with Druid under config/_common/log4j2.xml, and a sample file is also shown below:

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <Configuration status="WARN">
  3. <Appenders>
  4. <Console name="Console" target="SYSTEM_OUT">
  5. <PatternLayout pattern="%d{ISO8601} %p [%t] %c - %m%n"/>
  6. </Console>
  7. </Appenders>
  8. <Loggers>
  9. <Root level="info">
  10. <AppenderRef ref="Console"/>
  11. </Root>
  12. <!-- Uncomment to enable logging of all HTTP requests
  13. <Logger name="org.apache.druid.jetty.RequestLog" additivity="false" level="DEBUG">
  14. <AppenderRef ref="Console"/>
  15. </Logger>
  16. -->
  17. </Loggers>
  18. </Configuration>

My logs are really chatty, can I set them to asynchronously write?

Yes, using a log4j2.xml similar to the following causes some of the more chatty classes to write asynchronously:

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <Configuration status="WARN">
  3. <Appenders>
  4. <Console name="Console" target="SYSTEM_OUT">
  5. <PatternLayout pattern="%d{ISO8601} %p [%t] %c - %m%n"/>
  6. </Console>
  7. </Appenders>
  8. <Loggers>
  9. <AsyncLogger name="org.apache.druid.curator.inventory.CuratorInventoryManager" level="debug" additivity="false">
  10. <AppenderRef ref="Console"/>
  11. </AsyncLogger>
  12. <AsyncLogger name="org.apache.druid.client.BatchServerInventoryView" level="debug" additivity="false">
  13. <AppenderRef ref="Console"/>
  14. </AsyncLogger>
  15. <!-- Make extra sure nobody adds logs in a bad way that can hurt performance -->
  16. <AsyncLogger name="org.apache.druid.client.ServerInventoryView" level="debug" additivity="false">
  17. <AppenderRef ref="Console"/>
  18. </AsyncLogger>
  19. <AsyncLogger name ="org.apache.druid.java.util.http.client.pool.ChannelResourceFactory" level="info" additivity="false">
  20. <AppenderRef ref="Console"/>
  21. </AsyncLogger>
  22. <Root level="info">
  23. <AppenderRef ref="Console"/>
  24. </Root>
  25. </Loggers>
  26. </Configuration>