如何在dropwizard 0.6.2中将多个信息日志文件作为模块特定信息进行配置

时间:2017-11-17 06:38:24

标签: dropwizard

如果我在yaml文件中添加appender,则显示如下错误

错误:

  

无法识别的字段“appenders”(类   com.yammer.dropwizard.config.LoggingConfiguration $ FileConfiguration)

     

com.yammer.dropwizard.config.LoggingConfiguration [ “文件”] -

     
    

com.yammer.dropwizard.config.FileConfiguration [ “追加程序”])

  

我的yaml文件如下所示:

logging:

  # The default level of all loggers. Can be OFF, ERROR, WARN, INFO,
  # DEBUG, TRACE, or ALL.
  level: INFO

  # ...
  # Settings for logging to stdout.
  console:

    # If true, write log statements to stdout.
    enabled: true

    # Do not display log statements below this threshold to stdout.
    threshold: ALL

    # The time zone in which dates should be displayed.
    timeZone: UTC

    # A custom Logback format string.
    logFormat: null

  # Settings for logging to a file.
  file:

    # If true, write log statements to a file.
    enabled: true

    # Do not write log statements below this threshold to the file.
    threshold: ALL

    # The file to which current statements will be logged.
    currentLogFilename: ./logs/mylog.log

    # When the log file rotates, the archived log will be renamed to this and gzipped. The
    # %d is replaced with the previous day (yyyy-MM-dd). Custom rolling windows can be created
    # by passing a SimpleDateFormat-compatible format as an argument: "%d{yyyy-MM-dd-hh}".
    archivedLogFilenamePattern: ./logs/example-%d.log.gz

    # The number of archived files to keep.
    archivedFileCount: 5

    # The timezone used to format dates. HINT: USE THE DEFAULT, UTC.
    timeZone: UTC


  appenders:
  - type: file.
    currentLogFilename: ./logs/example1.log
    archivedLogFilenamePattern: ./logs/example1-%d.log.gz
    archivedFileCount: 5

任何帮助?

1 个答案:

答案 0 :(得分:0)

我一直在比较DropWizard的0.6.2和0.7.0版本的手册,看起来只是在0.7.0中引入了appenders功能:

http://www.dropwizard.io/0.6.2/manual/core.html#logging

http://www.dropwizard.io/0.7.0/docs/manual/core.html#logging

因此,此问题的解决方案应该是升级到0.7.0+版本的DW。

相关问题