You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Graham Clark <dy...@gmail.com> on 2014/06/20 12:31:14 UTC
Overriding the default log4j.properties
Hi,
I'm completely new to log4j so please forgive any stupid questions.
I have an application with a log4j.properties file in it which works
normally. I want to override the destination of the log file, though, so
I've created my own log4j.properties file and pointed to it with the
log4j.configuration=file.... JVM property. This works as expected and log4j
initialises and creates a log file in my new directory. This is where it
goes wrong (or at least doesn't do what I expect).
Having started up and created the correct log file, it then goes off and
reads the application's own log4j.properties file and creates another log
file in the old directory (that I don't want to write to). It then uses
this log file (and not the one it created first in my directory) to write
the log messages to. Is this working as expected? How do I stop it looking
at the old properties file and just take notice of what's in my new
properties file?
Here's the debug messages.
log4j: Using URL Ýfile:/u/ssdb008/log4j.properties¨ for automatic log4j
configuration.
log4j: Reading configuration from URL file:/u/ssdb008/log4j.properties
My PROPERTIES FILE
log4j: Parsing for Ýroot¨ with value=ÝDEBUG¨.
log4j: Level token is ÝDEBUG¨.
log4j: Category root set to DEBUG
log4j: Parsing for ÝError¨ with value=ÝERROR, ErrorOut¨.
log4j: Level token is ÝERROR¨.
log4j: Category Error set to ERROR
log4j: Parsing appender named "ErrorOut".
log4j: Parsing layout options for "ErrorOut".
log4j: Setting property ÝconversionPattern¨ to Ý%d{DATE} %m%n¨.
log4j: End of parsing for "ErrorOut".
log4j: Setting property Ýencoding¨ to ÝIBM-1047¨.
log4j: Setting property Ýfile¨ to Ý/u/ssdb008/waslogs/%j/alert_%n.log¨.
log4j: Process qualified filename:
/u/ssdb008/waslogs/WJS712S/alert_STC39857.log YES,
THIS IS WHERE I WANT IT TO GO
log4j: setFile called: /u/ssdb008/waslogs/WJS712S/alert_STC39857.log, true
log4j: setFile ended
log4j: Parsed "ErrorOut" options.
log4j: Handling log4j.additivity.Error=Ýnull¨
log4j: Parsing for ÝDebug¨ with value=ÝOFF, DebugOut¨.
log4j: Level token is ÝOFF¨.
log4j: Category Debug set to OFF
log4j: Parsing appender named "DebugOut".
log4j: Parsing layout options for "DebugOut".
log4j: Setting property ÝconversionPattern¨ to Ý%d{DATE} %m%n¨.
log4j: End of parsing for "DebugOut".
log4j: Parsed "DebugOut" options.
log4j: Handling log4j.additivity.Debug=Ýnull¨
log4j: Parsing for ÝTrace¨ with value=ÝINFO, TraceOut¨.
log4j: Level token is ÝINFO¨.
log4j: Category Trace set to INFO
log4j: Parsing appender named "TraceOut".
log4j: Parsing layout options for "TraceOut".
log4j: Setting property ÝconversionPattern¨ to Ý%d{DATE} %m%n¨.
log4j: End of parsing for "TraceOut".
log4j: Parsed "TraceOut" options.
log4j: Handling log4j.additivity.Trace=Ýnull¨
log4j: Finished configuring.
log4j: Trying to find Ýlog4j.properties¨ using context classloader
NO, WHY IS IT LOOKING HERE?
com.ibm.ws.classloader.CompoundClassLoader@b960b96
Local ClassPath:
/was610cfg/wjcell/wjnod712/AppServer/profiles/default/installedApps/wjcell/ebank_NWB_prod.ear/CSA.war/WEB-INF/cl
asses:/was610cfg/wjcell/wjnod712/AppServer/profiles/default/installedApps/wjcell/ebank_NWB_prod.ear/CSA.war
Delegation Mode: PARENT_FIRST.
log4j: Reading configuration from URL
file:/was610cfg/wjcell/wjnod712/AppServer/profiles/default/installedApps/wjcell/ebank_NWB_prod
.ear/CSA.war/WEB-INF/classes/log4j.properties
log4j: Parsing for Ýroot¨ with value=ÝDEBUG¨.
log4j: Level token is ÝDEBUG¨.
log4j: Category root set to DEBUG
log4j: Parsing for ÝError¨ with value=ÝERROR, ErrorOut¨.
log4j: Level token is ÝERROR¨.
log4j: Category Error set to ERROR
log4j: Parsing appender named "ErrorOut".
log4j: Parsing layout options for "ErrorOut".
log4j: Setting property ÝconversionPattern¨ to Ý%d{DATE} %m%n¨.
log4j: End of parsing for "ErrorOut".
log4j: Setting property Ýencoding¨ to ÝIBM-1047¨.
log4j: Setting property Ýfile¨ to Ý/software/waslogs/%j/alert_%n.log¨.
log4j: Process qualified filename:
/software/waslogs/WJS712S/alert_STC39857.log DON'T WANT
IT TO USE THIS FILE, HOW DO I STOP IT?
log4j: setFile called: /software/waslogs/WJS712S/alert_STC39857.log, true
log4j: setFile ended
log4j: Parsed "ErrorOut" options.
log4j: Handling log4j.additivity.Error=Ýnull¨
log4j: Parsing for ÝDebug¨ with value=ÝOFF, DebugOut¨.
log4j: Level token is ÝOFF¨.
log4j: Category Debug set to OFF
log4j: Parsing appender named "DebugOut".
log4j: Parsing layout options for "DebugOut".
log4j: Setting property ÝconversionPattern¨ to Ý%d{DATE} %m%n¨.
log4j: End of parsing for "DebugOut".
log4j: Parsed "DebugOut" options.
log4j: Handling log4j.additivity.Debug=Ýnull¨
log4j: Parsing for ÝTrace¨ with value=ÝINFO, TraceOut¨.
log4j: Level token is ÝINFO¨.
log4j: Category Trace set to INFO
log4j: Parsing appender named "TraceOut".
log4j: Parsing layout options for "TraceOut".
log4j: Setting property ÝconversionPattern¨ to Ý%d{DATE} %m%n¨.
log4j: End of parsing for "TraceOut".
log4j: Parsed "TraceOut" options.
log4j: Handling log4j.additivity.Trace=Ýnull¨
log4j: Finished configuring.
Cheers
Graham