You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Aneez Backer <an...@pramati.com> on 2008/09/11 07:15:02 UTC

how to Ignore log statements from some modules

hi

I am using a third party library for my application. I wish to ignore the 
log statements originating from this library, but at the same time I wish to 
log the statements for the classes I have written. What should be done in 
the log4j.xml file to achieve this ??

Thanks,

Aneez
--
Get everybody talkin' about your blog! Get the Free Tell-A-Friend widget
for your blog/site at http://tellafriend.socialtwist.com. 


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


Re: how to Ignore log statements from some modules

Posted by Aneez Backer <an...@pramati.com>.
hi

I got it working. I removed ".*" after "org.thirdparty".

 <logger name="org.thirdparty">
      <!-- Print only messages of level warn or above in the package 
org.thirdparty-->
      <level value="WARN"/>
 </logger>

Thanks

Aneez
--
Get everybody talkin' about your blog! Get the Free Tell-A-Friend widget
for your blog/site at http://tellafriend.socialtwist.com.


----- Original Message ----- 
From: "Aneez Backer" <an...@pramati.com>
To: "Log4J Users List" <lo...@logging.apache.org>
Sent: Thursday, September 11, 2008 11:30 AM
Subject: Re: how to Ignore log statements from some modules


>I tried two configurations, but it still shows the debug statements of the 
>thirdparty lib.
>
> I tried this first:
> -------------------------------------
> <category name="org.thirdpary.*" additivity="false">
>  <priority value="WARN" />
> <appender-ref ref="FILE" />
> </category>
>
> <category name="com.myapp.*" additivity="false">
>      <priority value="DEBUG" />
>      <appender-ref ref="FILE" />
> </category>
>
> <root>
>  <priority value="DEBUG" />
>  <appender-ref ref="FILE" />
> </root>
> ------------------------------------- 
>
> And then, I tried the this:
>
> -------------------------------------
> <logger name="org.thirdparty.*">
>      <!-- Print only messages of level warn or above in the package 
> com.foo -->
>      <level value="WARN"/>
> </logger>
>
> <category name="com.myapp.*" additivity="false">
>      <priority value="DEBUG" />
>      <appender-ref ref="FILE" />
> </category>
>
> <root>
>  <priority value="DEBUG" />
>  <appender-ref ref="FILE" />
> </root>
> -------------------------------------
>
>
> Both of them do not work. Is there some error in the configuration ??
>
> Thanks
>
> Aneez Backer
>
> --
> Get everybody talkin' about your blog! Get the Free Tell-A-Friend widget
> for your blog/site at http://tellafriend.socialtwist.com.
>
>
> ----- Original Message ----- 
> From: "Curt Arnold" <ca...@apache.org>
> To: "Log4J Users List" <lo...@logging.apache.org>
> Sent: Thursday, September 11, 2008 10:57 AM
> Subject: Re: how to Ignore log statements from some modules
>
>
>>
>> On Sep 11, 2008, at 12:15 AM, Aneez Backer wrote:
>>
>>> hi
>>>
>>> I am using a third party library for my application. I wish to  ignore 
>>> the log statements originating from this library, but at the  same time 
>>> I wish to log the statements for the classes I have  written. What 
>>> should be done in the log4j.xml file to achieve this ??
>>>
>>> Thanks,
>>>
>>> Aneez
>>
>> If the third party library uses logger names like 
>> "com.example.foolib....", then set the level of "com.example.foolib"  to 
>> OFF (or likely better ERROR) and the level of the root logger to  the 
>> level of interest in your own class, or you could set the root  logger to 
>> OFF or ERROR and set the level of "net.example.myapp" to  DEBUG or INFO.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org 


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


Re: how to Ignore log statements from some modules

Posted by Aneez Backer <an...@pramati.com>.
I tried two configurations, but it still shows the debug statements of the 
thirdparty lib.

I tried this first:
-------------------------------------
<category name="org.thirdpary.*" additivity="false">
  <priority value="WARN" />
 <appender-ref ref="FILE" />
</category>

<category name="com.myapp.*" additivity="false">
      <priority value="DEBUG" />
      <appender-ref ref="FILE" />
 </category>

 <root>
  <priority value="DEBUG" />
  <appender-ref ref="FILE" />
 </root>
------------------------------------- 

And then, I tried the this:

-------------------------------------
 <logger name="org.thirdparty.*">
      <!-- Print only messages of level warn or above in the package 
com.foo -->
      <level value="WARN"/>
 </logger>

<category name="com.myapp.*" additivity="false">
      <priority value="DEBUG" />
      <appender-ref ref="FILE" />
 </category>

 <root>
  <priority value="DEBUG" />
  <appender-ref ref="FILE" />
 </root>
-------------------------------------


 Both of them do not work. Is there some error in the configuration ??

Thanks

Aneez Backer

--
Get everybody talkin' about your blog! Get the Free Tell-A-Friend widget
for your blog/site at http://tellafriend.socialtwist.com.


----- Original Message ----- 
From: "Curt Arnold" <ca...@apache.org>
To: "Log4J Users List" <lo...@logging.apache.org>
Sent: Thursday, September 11, 2008 10:57 AM
Subject: Re: how to Ignore log statements from some modules


>
> On Sep 11, 2008, at 12:15 AM, Aneez Backer wrote:
>
>> hi
>>
>> I am using a third party library for my application. I wish to  ignore 
>> the log statements originating from this library, but at the  same time I 
>> wish to log the statements for the classes I have  written. What should 
>> be done in the log4j.xml file to achieve this ??
>>
>> Thanks,
>>
>> Aneez
>
> If the third party library uses logger names like 
> "com.example.foolib....", then set the level of "com.example.foolib"  to 
> OFF (or likely better ERROR) and the level of the root logger to  the 
> level of interest in your own class, or you could set the root  logger to 
> OFF or ERROR and set the level of "net.example.myapp" to  DEBUG or INFO.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org 


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


Re: how to Ignore log statements from some modules

Posted by Curt Arnold <ca...@apache.org>.
On Sep 11, 2008, at 12:15 AM, Aneez Backer wrote:

> hi
>
> I am using a third party library for my application. I wish to  
> ignore the log statements originating from this library, but at the  
> same time I wish to log the statements for the classes I have  
> written. What should be done in the log4j.xml file to achieve this ??
>
> Thanks,
>
> Aneez

If the third party library uses logger names like  
"com.example.foolib....", then set the level of "com.example.foolib"  
to OFF (or likely better ERROR) and the level of the root logger to  
the level of interest in your own class, or you could set the root  
logger to OFF or ERROR and set the level of "net.example.myapp" to  
DEBUG or INFO.

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