logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aggarwal <akansha.ag...@gmail.com>
Subject Re: class specific logging level
Date Mon, 11 Jun 2012 05:24:23 GMT

I think I have found the solution to my problem.

This thing is working with "org.apache.log4j.rolling.RollingFileAppender"
but not with "org.apache.log4j.RollingFileAppender"

Thanks for helping me out. :)



Douglas E Wegscheid wrote:
> 
> root being set to ERROR will not block the Myclass DEBUG; the 
> more-specific Myclass logger setting overrides the root setting.
> 
> Have you actually tried this?
> 
> package com.pkg;
> 
> import org.apache.log4j.Logger;
> import com.other.OtherClass;
> 
> public class MyClass {
>   static Logger logger = Logger.getLogger(MyClass.class);
>   public static void main (String[] args) {
>     logger.error ("MyClass error");
>     logger.info ("MyClass info");
>     logger.debug ("MyClass debug");
>     OtherClass.doThings();
>   }
> }
> 
> --
> 
> package com.other;
> import org.apache.log4j.Logger;
> 
> public class OtherClass {
>   static Logger logger = Logger.getLogger(OtherClass.class);
>   public static void doThings () {
>     logger.error ("OtherClass error");
>     logger.info ("OtherClass info");
>     logger.debug ("OtherClass debug");
>   }
> }
> 
> --
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
>  debug="true">
>  <appender name="Log1" class="org.apache.log4j.ConsoleAppender">
>   <layout class="org.apache.log4j.PatternLayout"/>
>  </appender>
> 
>  <logger name="com.pkg.MyClass" additivity="true">
>   <level value="DEBUG" />
>  </logger>
> 
>  <root>
>   <level value="INFO" />
>   <appender-ref ref="Log1" />
>  </root>
> </log4j:configuration>
> 
> -- results in --
> 
> MyClass error
> MyClass info
> MyClass debug
> OtherClass error
> OtherClass info
> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/class-specific-logging-level-tp33974515p33991200.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


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


Mime
View raw message