gpt4 book ai didi

tomcat6 - Hybris - hybris 和控制台日志分离

转载 作者:行者123 更新时间:2023-12-02 18:22:10 27 4
gpt4 key购买 nike

为了将 hybris 日志与控制台(catalina)包装器(tanuki)和 tomcat 分开,我创建了这两个配置。

#local.properties
log4j.appender.FILE = org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILE.File = ${HYBRIS_LOG_DIR}/tomcat/hybris.log
log4j.appender.FILE.Append = true
log4j.appender.FILE.DatePattern = '-'yyyy-MM-dd
log4j.appender.FILE.layout = org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} [%-5p|%X{RemoteAddr}|%X{TomcatSessionId}|%c] %m%n
log4j.rootLogger=INFO, FILE

这已放入 local.properties 并在 hybris.log 中创建日志我还创建了这个:

#log4j_init_tomcat.properties
log4j.appender.TOMCAT_FILE = org.apache.log4j.DailyRollingFileAppender
log4j.appender.TOMCAT_FILE.File = ${HYBRIS_LOG_DIR}/tomcat/tomcat.log
log4j.appender.TOMCAT_FILE.Append = true
log4j.appender.TOMCAT_FILE.DatePattern = '-'yyyy-MM-dd
log4j.appender.TOMCAT_FILE.layout = org.apache.log4j.PatternLayout
log4j.appender.TOMCAT_FILE.layout.ConversionPattern = %d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} [%-5p|%X{RemoteAddr}|%X{TomcatSessionId}|%c] %m%n
log4j.rootLogger=INFO, TOMCAT_FILE

它被放置在 log4j_init_tomcat.properties 中,它在 tanuki 包装器中加载为

wrapper.java.additional.22=-Dlog4j.configuration=file:%CATALINA_BASE%/conf/log4j_init_tomcat.properties

Tomcat.log 文件已创建,但为空,我看不出任何原因。

这是控制台日志文件的输出:

INFO   | jvm 1    | main    | 2015/09/16 22:36:32.711 | log4j: Reading configuration from URL file:../conf/log4j_init_tomcat.properties
INFO | jvm 1 | main | 2015/09/16 22:36:32.711 | log4j: Parsing for [root] with value=[INFO, TOMCAT_FILE].
INFO | jvm 1 | main | 2015/09/16 22:36:32.711 | log4j: Level token is [INFO].
INFO | jvm 1 | main | 2015/09/16 22:36:32.711 | log4j: Category root set to INFO
INFO | jvm 1 | main | 2015/09/16 22:36:32.711 | log4j: Parsing appender named "TOMCAT_FILE".
INFO | jvm 1 | main | 2015/09/16 22:36:32.711 | log4j: Parsing layout options for "TOMCAT_FILE".
INFO | jvm 1 | main | 2015/09/16 22:36:32.711 | log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} [%-5p|%X{RemoteAddr}|%X{TomcatSessionId}|%c] %m%n].
INFO | jvm 1 | main | 2015/09/16 22:36:32.711 | log4j: End of parsing for "TOMCAT_FILE".
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Setting property [datePattern] to ['-'yyyy-MM-dd].
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Setting property [append] to [true].
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Setting property [file] to [/opt/hybris/log/tomcat/tomcat.log].
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: setFile called: /opt/hybris/log/tomcat/tomcat.log, true
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: setFile ended
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Appender [TOMCAT_FILE] to be rolled at midnight.
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Parsed "TOMCAT_FILE" options.
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Finished configuring.
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Parsing for [root] with value=[INFO, FILE].
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Level token is [INFO].
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Category root set to INFO
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Parsing appender named "FILE".
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Parsing layout options for "FILE".
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} [%-5p|%X{RemoteAddr}|%X{TomcatSessionId}|%c] %m%n].
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: End of parsing for "FILE".
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Setting property [append] to [true].
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Setting property [file] to [/opt/hybris/log/tomcat/hybris.log].
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Setting property [datePattern] to ['-'yyyy-MM-dd].
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: setFile called: /opt/hybris/log/tomcat/hybris.log, true
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: setFile ended
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Appender [FILE] to be rolled at midnight.
INFO | jvm 1 | main | 2015/09/16 22:36:32.812 | log4j: Parsed "FILE" options.
INFO | jvm 1 | main | 2015/09/16 22:36:32.912 | log4j: Parsing for [org.apache.cxf] with value=[WARN].
INFO | jvm 1 | main | 2015/09/16 22:36:32.912 | log4j: Level token is [WARN].
INFO | jvm 1 | main | 2015/09/16 22:36:32.912 | log4j: Category org.apache.cxf set to WARN
INFO | jvm 1 | main | 2015/09/16 22:36:32.912 | log4j: Handling log4j.additivity.org.apache.cxf=[null]
INFO | jvm 1 | main | 2015/09/16 22:36:32.912 | log4j: Parsing for [de.hybris.platform.print.comet.utils.StopWatch] with value=[ALL].
INFO | jvm 1 | main | 2015/09/16 22:36:32.912 | log4j: Level token is [ALL].
INFO | jvm 1 | main | 2015/09/16 22:36:32.912 | log4j: Category de.hybris.platform.print.comet.utils.StopWatch set to ALL
INFO | jvm 1 | main | 2015/09/16 22:36:32.913 | log4j: Handling log4j.additivity.de.hybris.platform.print.comet.utils.StopWatch=[null]
INFO | jvm 1 | main | 2015/09/16 22:36:32.913 | log4j: Parsing for [print.soap.logging] with value=[ALL].
INFO | jvm 1 | main | 2015/09/16 22:36:32.913 | log4j: Level token is [ALL].
INFO | jvm 1 | main | 2015/09/16 22:36:32.913 | log4j: Category print.soap.logging set to ALL
INFO | jvm 1 | main | 2015/09/16 22:36:32.913 | log4j: Handling log4j.additivity.print.soap.logging=[null]
INFO | jvm 1 | main | 2015/09/16 22:36:32.913 | log4j: Parsing for [your.package] with value=[debug].
INFO | jvm 1 | main | 2015/09/16 22:36:32.913 | log4j: Level token is [debug].
INFO | jvm 1 | main | 2015/09/16 22:36:32.913 | log4j: Category your.package set to DEBUG
INFO | jvm 1 | main | 2015/09/16 22:36:32.913 | log4j: Handling log4j.additivity.your.package=[null]

我正在为logstash做这一切,以便它可以正确记录。我希望有人能帮助我!

谨致问候,信仰

最佳答案

你能试试这个吗..

log4j.rootLogger=INFO,TOMCAT_FILE,FILE 
log4j.logger.TOMCAT_FILE=INFO,TOMCAT_FILE
log4j.appender.TOMCAT_FILE.Threshold=INFO
log4j.additivity.com.baseframework=false
log4j.appender.TOMCAT_FILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.TOMCAT_FILE.File=${HYBRIS_LOG_DIR}/tomcat/tomcat.log
log4j.appender.TOMCAT_FILE.Append=true
log4j.appender.TOMCAT_FILE.DatePattern = '-'yyyy-MM-dd
log4j.appender.TOMCAT_FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.TOMCAT_FILE.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} [%-5p|%X{RemoteAddr}|%X{TomcatSessionId}|%c] %m%n

关于tomcat6 - Hybris - hybris 和控制台日志分离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32647047/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com