logging - 如何配置 Dropwizard 访问日志的位置和轮换?

标签 logging dropwizard access-log

我的日志配置如下所示:

logging:
  level: INFO

  loggers:
    "com.example.broker": DEBUG
    "org.apache.http.wire": DEBUG

  console:
    threshold: ERROR

  file:
    enabled: true
    currentLogFilename: /opt/broker/log/broker.log
    archivedLogFilenamePattern: /opt/broker/log/broker.%d.log.gz
    archivedFileCount: 14

这太棒了,我通过适当的轮换和清理将所有日志都放在给定的文件中。

除了仍然进入标准输出并因此最终(在我的情况下)在 /var/log/upstart/broker.log 中的访问日志。只能由 root 访问。我想使用相同或类似的日志配置将这些日志重定向到 /opt/broker/log/access.log .

这是可能的,如果是,如何?

最佳答案

由于从 codahale 迁移到 dropwizard.io,手册相关部分的位置现在是:
http://www.dropwizard.io/0.9.2/docs/manual/configuration.html#request-log

请注意,请求日志现在设置在 server 下而不是 http - 进行相关的 YAML 配置:

server:
  requestLog:
    timeZone: UTC
    appenders:
      - type: file
        currentLogFilename: /opt/broker/log/access.log
        threshold: ALL
        archive: true
        archivedLogFilenamePattern: /opt/broker/log/access.%d.log.gz
        archivedFileCount: 14

关于logging - 如何配置 Dropwizard 访问日志的位置和轮换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19179600/

相关文章:

java - 使用 Spring AOP 清理记录器

.net - 使用 Enterprise Library 登录到滚动 CSV 文件

java - Dropwizard + Jersey : "Not inside a request scope" when creating custom annotation

java - 什么时候写入访问日志?

tomcat - ClientAbortException/Broken Pipe 上的 Tomcat 访问日志中的 HTTP 状态代码 500

logging - access.log 未在 apache2 中记录消息

java - log4j 示例配置文件(属性文件)

groovy - 仅在特定子项目上运行 Gradle ShadowJar 插件

java - @Produces 和@Consumes 的 Jersey (dropwizard)默认媒体类型

arrays - 不要在日志中打印 secret