logback.xml file

The logback.xml configuration file can optionally set logging levels for the logs written to system.log and debug.log. The logging levels can also be set using nodetool setlogginglevels.

Options

appender name=”“…​

Specify log type and settings. Possible appender names are: SYSTEMLOG, DEBUGLOG, ASYNCDEBUGLOG, and STDOUT. SYSTEMLOG ensures that WARN and ERROR message are written synchronously to the specified file. DEBUGLOG and ASYNCDEBUGLOG ensure that DEBUG messages are written either synchronously or asynchronously, respectively, to the specified file. STDOUT writes all messages to the console in a human-readable format.

Example: <appender name=”SYSTEMLOG” class=”ch.qos.logback.core.rolling.RollingFileAppender”>

Specify the filename for a log.

Example: <file>$\{cassandra.logdir}/system.log</file>

Specify the level for a log. Part of the filter. Levels are: ALL, TRACE, DEBUG, INFO, WARN, ERROR, OFF. TRACE creates the most verbose log, ERROR the least.

Note

Note: Increasing logging levels can generate heavy logging output on a moderately trafficked cluster. You can use the nodetool getlogginglevels command to see the current logging configuration.

Default: INFO

Example: <level>INFO</level>

…​

Specify the policy for rolling logs over to an archive.

Example: <rollingPolicy class=”ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy”>

Specify the pattern information for rolling over the log to archive. Part of the rolling policy.

Example: <fileNamePattern>$\{cassandra.logdir}/system.log.%d{yyyy-MM-dd}.%i.zip</fileNamePattern>

Specify the maximum file size to trigger rolling a log. Part of the rolling policy.

Example: <maxFileSize>50MB</maxFileSize>

Specify the maximum history in days to trigger rolling a log. Part of the rolling policy.

Example: <maxHistory>7</maxHistory>

…​

Specify the format of the message. Part of the rolling policy.

Example: <maxHistory>7</maxHistory> Example: <encoder> <pattern>%-5level [%thread] %date{ISO8601} %F:%L - %msg%n</pattern> </encoder>

Contents of default logback.xml

  1. <configuration scan="true" scanPeriod="60 seconds">
  2. <jmxConfigurator />
  3. <!-- No shutdown hook; we run it ourselves in StorageService after shutdown -->
  4. <!-- SYSTEMLOG rolling file appender to system.log (INFO level) -->
  5. <appender name="SYSTEMLOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
  6. <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  7. <level>INFO</level>
  8. </filter>
  9. <file>${cassandra.logdir}/system.log</file>
  10. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  11. <!-- rollover daily -->
  12. <fileNamePattern>${cassandra.logdir}/system.log.%d{yyyy-MM-dd}.%i.zip</fileNamePattern>
  13. <!-- each file should be at most 50MB, keep 7 days worth of history, but at most 5GB -->
  14. <maxFileSize>50MB</maxFileSize>
  15. <maxHistory>7</maxHistory>
  16. <totalSizeCap>5GB</totalSizeCap>
  17. </rollingPolicy>
  18. <encoder>
  19. <pattern>%-5level [%thread] %date{ISO8601} %F:%L - %msg%n</pattern>
  20. </encoder>
  21. </appender>
  22. <!-- DEBUGLOG rolling file appender to debug.log (all levels) -->
  23. <appender name="DEBUGLOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
  24. <file>${cassandra.logdir}/debug.log</file>
  25. <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  26. <!-- rollover daily -->
  27. <fileNamePattern>${cassandra.logdir}/debug.log.%d{yyyy-MM-dd}.%i.zip</fileNamePattern>
  28. <!-- each file should be at most 50MB, keep 7 days worth of history, but at most 5GB -->
  29. <maxFileSize>50MB</maxFileSize>
  30. <maxHistory>7</maxHistory>
  31. <totalSizeCap>5GB</totalSizeCap>
  32. </rollingPolicy>
  33. <encoder>
  34. <pattern>%-5level [%thread] %date{ISO8601} %F:%L - %msg%n</pattern>
  35. </encoder>
  36. </appender>
  37. <!-- ASYNCLOG assynchronous appender to debug.log (all levels) -->
  38. <appender name="ASYNCDEBUGLOG" class="ch.qos.logback.classic.AsyncAppender">
  39. <queueSize>1024</queueSize>
  40. <discardingThreshold>0</discardingThreshold>
  41. <includeCallerData>true</includeCallerData>
  42. <appender-ref ref="DEBUGLOG" />
  43. </appender>
  44. <!-- STDOUT console appender to stdout (INFO level) -->
  45. <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  46. <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
  47. <level>INFO</level>
  48. </filter>
  49. <encoder>
  50. <pattern>%-5level [%thread] %date{ISO8601} %F:%L - %msg%n</pattern>
  51. </encoder>
  52. </appender>
  53. <!-- Uncomment bellow and corresponding appender-ref to activate logback metrics
  54. <appender name="LogbackMetrics" class="com.codahale.metrics.logback.InstrumentedAppender" />
  55. -->
  56. <root level="INFO">
  57. <appender-ref ref="SYSTEMLOG" />
  58. <appender-ref ref="STDOUT" />
  59. <appender-ref ref="ASYNCDEBUGLOG" /> <!-- Comment this line to disable debug.log -->
  60. <!--
  61. <appender-ref ref="LogbackMetrics" />
  62. -->
  63. </root>
  64. <logger name="org.apache.cassandra" level="DEBUG"/>
  65. <logger name="com.thinkaurelius.thrift" level="ERROR"/>
  66. </configuration>