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 Adam Krieg <ak...@marketaxess.com> on 2005/06/20 21:51:54 UTC

Segregating Loggers to different files at different levels

I'm integrating a third party library into our application.  This library
produces a lot of output at the DEBUG level that I'd like NOT to be in our
regular application log.  However recently we've encountered a problem that
we can only diagnose by turning on the debug level for this code.  I'd like
to be able to segregate this output to a separate file using a separate
appender.  

My log4j.xml looks something like this (irrelevant parts removed):


  <appender name="MainAppender"
class="org.jboss.logging.appender.DailyRollingFileAppender">
    <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
    <param name="Append" value="true"/>
    <param name="Threshold" value="DEBUG"/>

    <!-- Rollover at midnight each day -->
    <param name="DatePattern" value="'.'yyyy-MM-dd"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>

    </layout>
  </appender>

  <appender name="ThirdPartyAppender"
class="org.jboss.logging.appender.DailyRollingFileAppender">
    <param name="File" value="${jboss.server.home.dir}/log/thirdParty.log"/>
    <param name="Append" value="true"/>
    <param name="Threshold" value="DEBUG"/>

    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>

    </layout>
  </appender>

 <category name="com.thirdparty">
 	<priority value="DEBUG"/>
  	 <appender-ref ref="ThirdPartyDebug"/>
  </category>

 <category name="com.thirdparty">
 	<priority value="WARN"/>
  </category>


  <root>
  	<priority value="TRACE" class="org.jboss.logging.XLevel"/>
    	<appender-ref ref="CONSOLE"/>
    	<appender-ref ref="MainAppender"/>
  </root>


What ends up happening is that I get debug level output in both the
MainAppender and the ThirdPartyAppender.  I'd like to only get WARN and
above in the Main appender for the thirdparty library and I'd like to get
Debug in the ThirdParty log.


Any ideas?

Thanks,
Adam





----------------------------------------------------------------------------
----------------------------------------.
 
.The information contained in and accompanying this communication is
strictly confidential and intended solely for the use of the intended
recipient(s).
If you have received it by mistake please let us know by reply and then
delete it from your system; you should not copy the message or disclose its
content to anyone.
MarketAxess reserves the right to monitor the content of emails sent to or
from its systems.
Any comments or statements made are not necessarily those of MarketAxess.
For more information, please visit www.marketaxess.com. MarketAxess Europe
Limited is regulated in the UK by the FSA, registered in England no.
4017610, registered office at 71 Fenchurch Street, London, EC3M 4BS.
Telephone (020) 7709 3100.
MarketAxess Corporation is regulated in the USA by the SEC and the NASD,
incorporated in Delaware, executive offices at 140 Broadway, New York, NY
10005. Telephone (1) 212 813 6000.


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


Re: Segregating Loggers to different files at different levels

Posted by James Stauffer <st...@gmail.com>.
First, I don't think that you can have two lines with the same category.
 <category name="com.thirdparty">

Do you want debug for code outside of the 3rd party library?


On 6/20/05, Adam Krieg <ak...@marketaxess.com> wrote:
> I'm integrating a third party library into our application.  This library
> produces a lot of output at the DEBUG level that I'd like NOT to be in our
> regular application log.  However recently we've encountered a problem that
> we can only diagnose by turning on the debug level for this code.  I'd like
> to be able to segregate this output to a separate file using a separate
> appender.
> 
> My log4j.xml looks something like this (irrelevant parts removed):
> 
> 
>   <appender name="MainAppender"
> class="org.jboss.logging.appender.DailyRollingFileAppender">
>     <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
>     <param name="Append" value="true"/>
>     <param name="Threshold" value="DEBUG"/>
> 
>     <!-- Rollover at midnight each day -->
>     <param name="DatePattern" value="'.'yyyy-MM-dd"/>
>     <layout class="org.apache.log4j.PatternLayout">
>       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
> 
>     </layout>
>   </appender>
> 
>   <appender name="ThirdPartyAppender"
> class="org.jboss.logging.appender.DailyRollingFileAppender">
>     <param name="File" value="${jboss.server.home.dir}/log/thirdParty.log"/>
>     <param name="Append" value="true"/>
>     <param name="Threshold" value="DEBUG"/>
> 
>     <layout class="org.apache.log4j.PatternLayout">
>       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
> 
>     </layout>
>   </appender>
> 
>  <category name="com.thirdparty">
>         <priority value="DEBUG"/>
>          <appender-ref ref="ThirdPartyDebug"/>
>   </category>
> 
>  <category name="com.thirdparty">
>         <priority value="WARN"/>
>   </category>
> 
> 
>   <root>
>         <priority value="TRACE" class="org.jboss.logging.XLevel"/>
>         <appender-ref ref="CONSOLE"/>
>         <appender-ref ref="MainAppender"/>
>   </root>
> 
> 
> What ends up happening is that I get debug level output in both the
> MainAppender and the ThirdPartyAppender.  I'd like to only get WARN and
> above in the Main appender for the thirdparty library and I'd like to get
> Debug in the ThirdParty log.
> 
> 
> Any ideas?
> 
> Thanks,
> Adam
> 
> 
> 
> 
> 
> ----------------------------------------------------------------------------
> ----------------------------------------.
> 
> .The information contained in and accompanying this communication is
> strictly confidential and intended solely for the use of the intended
> recipient(s).
> If you have received it by mistake please let us know by reply and then
> delete it from your system; you should not copy the message or disclose its
> content to anyone.
> MarketAxess reserves the right to monitor the content of emails sent to or
> from its systems.
> Any comments or statements made are not necessarily those of MarketAxess.
> For more information, please visit www.marketaxess.com. MarketAxess Europe
> Limited is regulated in the UK by the FSA, registered in England no.
> 4017610, registered office at 71 Fenchurch Street, London, EC3M 4BS.
> Telephone (020) 7709 3100.
> MarketAxess Corporation is regulated in the USA by the SEC and the NASD,
> incorporated in Delaware, executive offices at 140 Broadway, New York, NY
> 10005. Telephone (1) 212 813 6000.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 


-- 
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

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