This sort of confusion is almost always caused by some other configuration file being loaded rather than the one you expect.  I suggest setting -Dlog4j.debug=true on the command line (in this case, the command line starting the appserver), which will cause Log4j to provide information on how it is configuring the application.

Note that it's also possible the the correct config file is being loaded, but then some application code is dynamically reconfiguring without you realizing it.  Ensure that no code is manually configuration Log4j after initialization.


Jake

On Wed, 7 Nov 2012 17:20:09 +0800 (SGT)
 tong123123 <tong123...@yahoo.com.hk> wrote:
I have a web application and it use my another application packed as jar. in war\web-inf\classes\log4j.properties, I wrote

log4j.rootLogger=WARN, A1  log4j.appender.A1=org.apache.log4j.ConsoleAppender  log4j.appender.A1.layout.ConversionPattern=%d %-5p (%13F:%L) %3x -%m%n 
then in my web application I wrote

private static Logger logger = Logger.getLogger(MyWebApp.class);
logger.debug("debug");
logger.warn("warn");

the output is as expected, only "warn" will be shown.
but in my jar application, I wrote

private static Logger logger = Logger.getLogger(JarApp.class);
logger.warn("warn in jar"); 
there is no output in console!!!
and if I change the log4j.properties log level to DEBUG

log4j.rootLogger=, A1

then the "warn in jar" will be shown in console, but with %-5p shown as DEBUG.
That is, even in my jar application, I wrote

logger.warn("warn in jar"); 
log4j still treat it as DEBUG level, why will this happen?
I am using log4j-1.2.16.jar


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to