Hi,
I have tried it with the following configuration :
<appender name="Log1" class="org.apache.log4j.RollingFileAppender">
<layout class="org.apache.log4j.PatternLayout">
</layout>
</appender>
<logger name="MyClass" additivity="true">
<level value="DEBUG" />
</logger>
<root>
<priority value="INFO" />
<appender-ref ref="Log1" />
</root>
I want MyClass logs of DEBUG level and all other classes of ERROR in
"log1.log" file as mentioned in logger "Log1". But it isnt happening. Am not
getting any DEBUG logs in "log1.log" whereas if I set the level in appender
"Log1" to DEBUG, I do get the DEBUG logs of Myclass in log1.log. I am sorry
if am still making some mistake here. Please correct me where am I wrong.
Thanks for such quick replies.
Jacob Kjome wrote:
>
>
> What I've provided does exactly what you are asking for. Setting your
> class
> logging level to DEBUG overrides the inherited level from root for the
> specified logger name. Why don't you just try it and see what it does
> rather
> than speculate on why you believe it wouldn't work? You can also read try
> reading the docs...
>
> http://logging.apache.org/log4j/1.2/manual.html
>
> Jake
>
> On Thu, 7 Jun 2012 20:44:05 -0700 (PDT)
> aggarwal <[email protected]> wrote:
>>
>> So when root level is ERROR and i set Myclass level to DEBUG, how will
>> the
>> Myclass's DEBUG logs get logged since the root level is ERROR and it will
>> block the DEBUG logs ? What i know is that, if I set root level to DEBUG
>> and
>> some particular class (say Myclass) logger level to ERROR then, all
>> classes'
>> logs of DEBUG will get logged but not of Myclass as its restricted to
>> ERROR.
>> But what I want is the vice-versa. I want ERROR level of all classes and
>> DEBUG of only few important classes. I am new to log4j so maybe what i am
>> sayin is wrong.
>>
>>
>>
>> Jacob Kjome wrote:
>>>
>>>
>>> If you name your loggers by class name, then sure. This is standard
>>> logging
>>> configuration, not some extra special workaround.
>>>
>>> <logger name="com.mypackage.Myclass">
>>> <level value="debug"/>
>>> <!-- inherits A1 appender from root, applies only to
>>> com.mypackage.MyClass
>>> -->
>>> </logger>
>>> <logger name="com.myotherpackage">
>>> <level value="debug"/>
>>> <!-- inherits A1 appender from root, applies to all classes in
>>> "com.myotherpackage" -->
>>> </logger>
>>> <root>
>>> <level value="error"/>
>>> <appender-ref ref="A1"/>
>>> </root>
>>>
>>>
>>> Jake
>>>
>>> On Thu, 7 Jun 2012 01:51:07 -0700 (PDT)
>>> aggarwal <[email protected]> wrote:
>>>>
>>>> Hi,
>>>>
>>>> Is it possible to set logging level for few selected classes in
>>>> appender
>>>> to
>>>> DEBUG and rest all ERROR ? Is there any combination of filter that can
>>>> do
>>>> this ?
>>>> --
>>>> View this message in context:
>>>>http://old.nabble.com/class-specific-logging-level-tp33974515p33974515.html
>>>> Sent from the Log4j - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>>For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>>http://old.nabble.com/class-specific-logging-level-tp33974515p33979415.html
>> Sent from the Log4j - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>>For additional commands, e-mail: [email protected]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
--
View this message in context:
http://old.nabble.com/class-specific-logging-level-tp33974515p33982398.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]