I know the reason now, my core module .class file is not updated in the war and so it still has the value logger.debug()
although I change the code to logger.warn() in .java file; ________________________________ 寄件人︰ tong123123 <[email protected]> 收件人︰ Log4J Users List <[email protected]> 傳送日期︰ 2012年11月8日 (週四) 11:45 AM 主題︰ 回覆︰ all log4j level in jar application is treated as debug level I have added -Dlog4j.debug=true and the console output seems using the right log4j.prpoerties, the appserver is weblogic 10.3.4, the output in console is: log4j: Trying to find [log4j.xml] using context classloader weblogic.utils.classloaders.ChangeAwareClassLoader@5aa997 finder: weblogic.utils.classloaders.CodeGenClassFinder@ab2790 annotation: [email protected]. log4j: Trying to find [log4j.xml] using weblogic.utils.classloaders.ChangeAwareClassLoader@5aa997 finder: weblogic.utils.classloaders.CodeGenClassFinder@ab2790 annotation: [email protected] class loader. log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource(). log4j: Trying to find [log4j.properties] using context classloader weblogic.utils.classloaders.ChangeAwareClassLoader@5aa997 finder: weblogic.utils.classloaders.CodeGenClassFinder@ab2790 annotation: [email protected]. log4j: Using URL [zip:D:/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/DebugLevelDemo-Webapp/e8su8/war/WEB-INF/lib/_wl_cls_gen.jar!/log4j.properties] for automatic log4j configuration. log4j: Reading configuration from URL zip:D:/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/DebugLevelDemo-Webapp/e8su8/war/WEB-INF/lib/_wl_cls_gen.jar!/log4j.properties log4j: Parsing for [root] with value=[, A1, A2]. log4j: Parsing appender named "A1". log4j: Parsing layout options for "A1". log4j: Setting property [conversionPattern] to [%d %-5p (%13F:%L) %3x - %m%n]. log4j: End of parsing for "A1". log4j: Parsed "A1" options. log4j: Parsing appender named "A2". log4j: Parsing layout options for "A2". log4j: Setting property [conversionPattern] to [%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n]. log4j: End of parsing for "A2". log4j: Setting property [file] to [./debugleveldemo_logs/debugleveldemo.log]. log4j: Setting property [datePattern] to ['.'yyyy-MM-dd]. log4j: setFile called: ./debugleveldemo_logs/debugleveldemo.log, true log4j: setFile ended log4j: Appender [A2] to be rolled at midnight. log4j: Parsed "A2" options. log4j: Finished configuring. 2012-11-08 11:13:52,699 DEBUG (DebugLevelDemoServiceImpl.java:30) - debug 2012-11-08 11:13:52,714 WARN (DebugLevelDemoServiceImpl.java:31) - warn 2012-11-08 11:13:52,714 ERROR (DebugLevelDemoServiceImpl.java:32) - error 2012-11-08 11:13:52,714 DEBUG (DBConnection.java:45) - Thu Nov 08 11:13:52 CST 2012after InitialContext() 2012-11-08 11:13:52,714 DEBUG (DBConnection.java:48) - jndiName = jdbc/debugleveldemo 2012-11-08 11:13:52,714 DEBUG (DBConnection.java:51) - Thu Nov 08 11:13:52 CST 2012 after ctx.lookup('jdbc/debugleveldemo') 2012-11-08 11:13:52,792 DEBUG (DBConnection.java:54) - JNDI DB Connection success after deploying to weblogic, the log4j.properties is located at WEB-INF/lib/_wl_cls_gen.jar (this .jar should be generated automatically by weblogic, not me) and my application jar is in WEB-INF/lib/DebugLevelDemo-Core-1.0.0.jar as seen, the rootLogger is at debug level, and in the last 4st lines, it output DEBUG (DBConnection.java:45) but I am using logger.WARN in my application code, so the output is wrong, log4j treats it as DEBUG level. and if I change the rootLogger to Warn level, then the last 4st lines will not be outputted to console!! this only occur for code in DebugLevelDemo-Core.1.0.0 jar, for code in _wl_cls_gen.jar, everything is correct. ________________________________ 寄件人︰ Jacob Kjome <[email protected]> 收件人︰ Log4J Users List <[email protected]>; tong123123 <[email protected]> 傳送日期︰ 2012年11月7日 (週三) 10:10 PM 主題︰ Re: all log4j level in jar application is treated as debug level 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 <[email protected]> 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: [email protected] For additional commands, e-mail: [email protected]
