logstash Hybris -hybris和控制台日志的分离

gdx19jrr  于 2022-12-09  发布在  Logstash
关注(0)|答案(1)|浏览(153)

为了将hybris日志从控制台( Catalina ) Package 器(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和创建日志在hybrids.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中,log4j_init_tomcat.properties作为

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做这一切,这样它就可以正确地记录。我希望有人能帮助我!
谨致问候,Fide

atmip9wb

atmip9wb1#

你能试试这个吗?

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

相关问题