3

in order to separate the hybris logs from console (catalina) wrapper (tanuki) and tomcat I created these two configs.

#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

This was put into the local.properties and creates logs in hybris.log And I also created this:

#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

which is placed in the log4j_init_tomcat.properties which is load in the tanuki wrapper as

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

Tomcat.log file is created but empty and I don't see any reason why.

This is an output from the console log file:

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]

I am doing all this for logstash so it can be logged properly. I hope someone can help me!

With kind regards, Fide

Fide
  • 109
  • 1
  • 3
  • 8

1 Answers1

0

Can you try this ..

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
Free-Minded
  • 5,322
  • 6
  • 50
  • 93
  • Hi Shreshtt, this is confusing me, should this be for hybris.log or tomcat.log? I mean is this part of local.properties or log4j_init_tomcat.properties I put this into log4j_init_tomcat.properties and it filled hybris.log with more information, although I used tomcat.log instead of hybris.log you mentioned here. – Fide Sep 21 '15 at 10:11
  • This completely drives me crazy, I have no idea why tomcat.log is not being used... – Fide Sep 23 '15 at 07:13
  • I tried the above configs in the two property files. But both Hybris.log and tomcat.log are created but empty. Did you fix the problem you had of empty tomcat.log – user132797 Jun 02 '17 at 08:14