我的日志配置如下所示:
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/