So, I found out the why RollingFileAppender wasn't behaving like
ConsoleAppender. Because I had mentioned a threshold level in
RollingFileAppender but not in ConsoleAppender. Removing threshold tag from
RollingFileAppender worked.
aggarwal wrote:
>
> 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-tp33974515p33992013.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
|