dropwizard的日志记录配置,以自定义日志格式将所有内容记录到一个文件中 [英] Logging configuration for dropwizard to log everything into one file with custom log format
问题描述
我使用的是dropwizard 0.9.2,不得不将杰克逊升级到2.7.3 以在以下位置进行以下配置至少开始:
服务器:applicationConnectors:-类型:http端口:8080adminConnectors:-类型:http端口:8081requestLog:时区:UTC追加者:-类型:控制台logFormat:%d {HH:mm:ss.SSS} [%thread]%-5level%logger {36}-%msg%n"-类型:文件currentLogFilename:./logs/vrp-app.logarchivedLogFilenamePattern:./logs/vrp-app.%d.log.gzlogFormat:%d {HH:mm:ss.SSS} [%thread]%-5level%logger {36}-%msg%n"日志记录:等级:INFO记录器:"org.hibernate":级别:调试追加者:-类型:控制台时区:UTClogFormat:%d {HH:mm:ss.SSS} [%thread]%-5level%logger {36}-%msg%n"-类型:文件时区:UTCcurrentLogFilename:./logs/vrp-app.logarchivedLogFilenamePattern:./logs/vrp-app.%d.log.gzarchivedFileCount:5logFormat:%d {HH:mm:ss.SSS} [%thread]%-5level%logger {36}-%msg%n"
但是请求日志的日志格式仍然与其余日志格式不同:
15:46:42.717 [main] INFO org.eclipse.jetty.server.Server-启动@ 3751ms127.0.0.1--[14/Jun/2016:13:46:48 +0000]"GET/users HTTP/1.1" 415 56-""curl/7.35.0" 136
仅保留"-type"行以希望从 logging
部分中选择配置也是不起作用的.
我在做什么错了?
这应该根据此讨论 >
可以为请求日志和普通日志"指定相同的日志.为什么要完全分开?
requestLog logFormat不适用于0.9.2.您必须转到1.0.0-rc3(最新)的dropwizard版本.
而且格式与 http://logback.qos.ch/access.html中指定的格式略有不同
更多参考: https://www.loggly.com/ultimate-guide/apache-logging-basics/
I'm using dropwizard 0.9.2 and had to upgrade jackson to 2.7.3 to make the following configuration at least starting:
server:
applicationConnectors:
- type: http
port: 8080
adminConnectors:
- type: http
port: 8081
requestLog:
timeZone: UTC
appenders:
- type: console
logFormat: "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
- type: file
currentLogFilename: ./logs/vrp-app.log
archivedLogFilenamePattern: ./logs/vrp-app.%d.log.gz
logFormat: "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
logging:
level: INFO
loggers:
"org.hibernate":
level: DEBUG
appenders:
- type: console
timeZone: UTC
logFormat: "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
- type: file
timeZone: UTC
currentLogFilename: ./logs/vrp-app.log
archivedLogFilenamePattern: ./logs/vrp-app.%d.log.gz
archivedFileCount: 5
logFormat: "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n"
But still the log format of the request log is different than the rest:
15:46:42.717 [main] INFO org.eclipse.jetty.server.Server - Started @3751ms
127.0.0.1 - - [14/Jun/2016:13:46:48 +0000] "GET /users HTTP/1.1" 415 56 "-" "curl/7.35.0" 136
Just keeping the "-type" lines in the hope that the config is picked from the logging
section also does not work.
What am I doing wrong?
This should work according to this discussion
And is it okay to specify the same log for request log and 'normal log'. Why is this separated at all?
requestLog logFormat is not implemented for 0.9.2. You have to move to 1.0.0-rc3 (latest) dropwizard version.
And the formatting is bit different as specified in http://logback.qos.ch/access.html
more ref: https://www.loggly.com/ultimate-guide/apache-logging-basics/
这篇关于dropwizard的日志记录配置,以自定义日志格式将所有内容记录到一个文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!