Logging in Dropwizard

Relevant Documentation

  • Dropwizard: http://www.dropwizard.io/0.9.2/docs/manual/configuration.html
  • Logback: https://logback.qos.ch/manual/architecture.html

What you need to know

  • Levels: TRACE < DEBUG < INFO < WARN < ERROR
  • How do I configure logging in dropwizard so that logs go to different (relevant) files?
    • Define a logger (by classpath prefix) and a specific appender.
    • Appenders should be specific files.
    • You can specify threshold or level filters.
logging:
  level: INFO
  loggers:
    "io.dropwizard": 
      level: INFO
      additive: false
      appenders:
        - type: file
          currentLogFilename: $APP_HOME/var/log/dropwizard.log
          archivedLogFilenamePattern: $APP_HOME/var/log/dropwizard-%d.log.gz
          archivedFileCount: 5
    "org.hibernate.SQL":
      level: DEBUG
      additive: false
      appenders:
        - type: file
          currentLogFilename: $APP_HOME/var/log/app-sql.log
          archivedLogFilenamePattern: $APP_HOME/var/log/app-sql-%d.log.gz
          archivedFileCount: 5
  appenders:
    - type: console

你可能感兴趣的:(Logging in Dropwizard)