我的 Dropwizard 出现了问题(版本 1.3.8) 应用程序将 HTTP 请求记录到文件中。我遵循了 Dropwizard 的文档用于配置 YAML 文件,我的config.yml
外观如下:
logging:
level: INFO
loggers:
com.nikolas.master_thesis: DEBUG
appenders:
- type: file
currentLogFilename: /home/nikola/Documents/DWApp-LOGs/DW-Bookshop_LOG.log
threshold: ALL
queueSize: 512
archive: true
archivedLogFilenamePattern: /home/nikola/Documents/DWApp-LOGs/DW-Bookshop_LOG-%d.log
archivedFileCount: 5
timeZone: UTC
logFormat: "%-5p [%d{ISO8601,UTC}] %c: %m%n%rEx"
# logFormat: "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
# logFormat: “%h %l %u %t “%r“ %s %b “%{Referer}i“ “%{User-Agent}i““ combined
# logFormat: '%h %l %u %t '%r' %\\>s %b '%{Referer}i' '%{User-Agent}i''
# logFormat: "%d{HH:mm:ss.SSS} [%thread] %-5level %com.nikolas.master_thesis.examples.`config-kt`.logger{36} - %msg%n"
# logFormat: “%h %l %u %t “%r“ %s %b “%{Referer}i“ “%{User-Agent}i““
# logFormat: "%h %l %u %t \"%r\" %s %O \"%{Referer}i\""
# logFormat: “%h %l %u %t “%r“ %\\>s %b “%{Referer}i“ “%{User-Agent}i““
# logFormat: "%h %l %u %t \"%r\" \"%>s\" %O \"%{Referer}i\""
# logFormat: "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
# logFormat: combined
# logFormat: "%h %l %u %t \"%r\" %>s %b" /etc/httpd
# logFormat: “%h %l %u %t “%r” %s %b “%{User-Agent}i””
# logFormat: "%h %l %u %t \"%r\" %>s %b" /etc/httpd
# logFormat: "%h %l %u %t \"%r\" %>s %b"
# logFormat: "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
bufferSize: 8KB
immediateFlush: true
# filterFactories:
# - type: URI
- type: console
threshold: ALL
queueSize: 512
discardingThreshold: 0
timeZone: UTC
target: stdout
logFormat: "%-5p [%d{ISO8601,UTC}] %c: %m%n%rEx"
事实是 HTTP 请求在控制台中像这样记录:
192.168.1.5 - - [09/Aug/2020:10:08:05 +0000] "GET /api/orders HTTP/1.1" 200 14094 "-" "Apache-HttpClient/4.5.10 (Java/1.8.0_161)" 710
...我还想将其记录在文件中,但它根本没有记录它!我尝试使用注释logFormat
,但对于每个注释logFormat
值我都会收到错误。例如,logFormat: "%h %l %u %t \"%r\" %>s %b"
当我在终端中运行它时(我正在使用RMI 参数从远程机器收集 JMX 样本):
java -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=1616 -Dcom.sun.management.jmxremote.rmi.port=1616 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -jar ./target/DW-Bookshop-1.0-SNAPSHOT.jar server config.yml
...我收到 NumberFormatException:
java.lang.NumberFormatException: For input string: ">"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at ch.qos.logback.core.pattern.FormatInfo.valueOf(FormatInfo.java:73)
at ch.qos.logback.core.pattern.parser.Parser.T(Parser.java:136)
at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:96)
at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115)
at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100)
at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115)
at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100)
at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115)
at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100)
at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115)
at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100)
at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115)
at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100)
at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115)
at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100)
at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115)
at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100)
at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115)
at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100)
at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115)
at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100)
at ch.qos.logback.core.pattern.parser.Parser.Eopt(Parser.java:115)
at ch.qos.logback.core.pattern.parser.Parser.E(Parser.java:100)
at ch.qos.logback.core.pattern.parser.Parser.parse(Parser.java:91)
at ch.qos.logback.core.pattern.PatternLayoutBase.start(PatternLayoutBase.java:83)
at io.dropwizard.logging.AbstractAppenderFactory.buildLayout(AbstractAppenderFactory.java:243)
at io.dropwizard.logging.AbstractOutputStreamAppenderFactory.build(AbstractOutputStreamAppenderFactory.java:25)
at io.dropwizard.logging.DefaultLoggingFactory.configure(DefaultLoggingFactory.java:143)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:83)
at io.dropwizard.cli.Cli.run(Cli.java:78)
at io.dropwizard.Application.run(Application.java:93)
at com.nikolas.master_thesis.DropwizardMasterThesisApplication.main(DropwizardMasterThesisApplication.java:35)
顺便说一句,我正在跑步Fedora 31 操作系统我正在使用Java 8. 非常感谢任何建议/帮助。