logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Drake <Tom.Dr...@tavant.com>
Subject RE: Exclude a class from a particular appender.....
Date Tue, 06 Jan 2004 21:00:23 GMT
You've got the same category defined twice. That is going to be a problem.
Also, try adding an child element to set additivity as follows:

	<category name="com.shawmut.portal.scheduler">
		<priority value="INFO"/>
		<additivity value="false"/>
		<appender-ref ref="SCHEDULER"/>
	</category>


This should cause all messages logged at INFO (and above) to be logged only
via the SCHEDULER appender. All other messages should be logged via CONSOLE
and FILE appenders based on how you've defined your root category.

Tom Drake

-----Original Message-----
From: Pitre, Russell [mailto:RPITRE@shawmut.com] 
Sent: Tuesday, January 06, 2004 12:39 PM
To: Log4J Users List
Subject: RE: Exclude a class from a particular appender.....

Ok.  I took a look at log4j.xml and I didn't find an example of I'm
trying to do........here's my log4j.xml file.......if you take a look at
the "Userdefined Categories" you'll notice where I'm using the
additivity="false" value to eliminate logs being sent to the console.
Well, that's what I'm trying to do at least.....I've googled all day
long but to no avail........so frustrating....and I can't find anything
within the Jboss docs either.....(I have the CS subscription, and I'll
reserve my comments about their documentation)......So if anyone can
help me out I would really appreciate it..

========================================================================
==
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">

  <!-- ================================= -->
  <!-- Preserve messages in a local file -->
  <!-- ================================= -->

  <!-- A time/date based rolling appender -->
  <appender name="FILE"
class="org.jboss.logging.appender.DailyRollingFileAppender">
    <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
    <param name="Append" value="false"/>
	<param name="Threshold" value="info"/>

    <!-- Rollover at midnight each day -->
    <param name="DatePattern" value="'.'yyyy-MM-dd"/>

    <!-- Rollover at the top of each hour
    <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
    -->

    <layout class="org.apache.log4j.PatternLayout">
      <!-- The default pattern: Date Priority [Category] Message\n -->
      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>

      <!-- The full pattern: Date MS Priority [Category] (Thread:NDC)
Message\n
      <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x)
%m%n"/>
       -->
    </layout>	    
  </appender>


  <!-- ============================== -->
  <!-- Append messages to the console -->
  <!-- ============================== -->

  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
    <param name="Target" value="System.out"/>
	<!-- CHANGE "Value" to debug, info, warn, etc...-->
    <param name="Threshold" value="info"/>

    <layout class="org.apache.log4j.PatternLayout">
      <!-- The default pattern: Date Priority [Category] Message\n -->
      <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}]
%m%n"/>
    </layout>
  </appender>
  
  <appender name="JSR77" class="org.apache.log4j.FileAppender">
    <param name="Append" value="false"/>
    <param name="File" value="${jboss.server.home.dir}/log/jsr77.log"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}]
%m%n"/>
    </layout>
  </appender> 

  <!-- ============================= -->
  <!--      User Defined Appenders   -->
  <!-- ============================= -->

  <appender name="SCHEDULER"
class="org.jboss.logging.appender.RollingFileAppender">
    <param name="File" value="${jboss.server.home.dir}/log/guyute.log"/>
	<param name="Threshold" value="debug"/>
    <param name="Append" value="false"/>
    <param name="MaxFileSize" value="500KB"/>
    <param name="MaxBackupIndex" value="1"/>

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


  <!-- ============================== -->
  <!--      User Defined Categories   -->
  <!-- ============================== -->

	<category name="com.shawmut.portal.scheduler">
		<priority value="INFO"/>
		<appender-ref ref="SCHEDULER"/>
	</category>

	<category name="com.shawmut.portal.scheduler"
additivity="false">
		<priority value="INFO"/>
		<appender-ref ref="CONSOLE"/>
	</category>

  <!-- ======================= -->
  <!-- Setup the Root category -->
  <!-- ======================= -->

  <root>
	<priority value="debug"/>
    <appender-ref ref="CONSOLE"/>
    <appender-ref ref="FILE"/>
  </root>
  
</log4j:configuration>
========================================================================
==
-----Original Message-----
From: Robert Augustyn [mailto:augustynr@yahoo.com] 
Sent: Tuesday, January 06, 2004 2:28 PM
To: 'Log4J Users List'
Subject: RE: Exclude a class from a particular appender.....

Pitre,
Look into an log4j.xml in conf of the jboss.
It has examples of what you need.
robert

-----Original Message-----
From: Tom Drake [mailto:Tom.Drake@tavant.com] 
Sent: Tuesday, January 06, 2004 2:10 PM
To: 'Log4J Users List'
Subject: RE: Exclude a class from a particular
appender.....


I assume that your Root logger is set to use the
CONSOLE appender. That
being the case, you can set the 'additive' parameter
of your
com.shawmut.portal.scheduler logger to false. This
way, any messages
logged to this logger will NOT be sent to it's parent
logger (e.g.
Root/CONSOLE) as well.



-----Original Message-----
From: Pitre, Russell [mailto:RPITRE@shawmut.com] 
Sent: Tuesday, January 06, 2004 8:50 AM
To: log4j-user@logging.apache.org
Subject: Exclude a class from a particular
appender.....

Hello All-

 

I'm using Jboss 3.2 and I'm trying to figure out how
to exclude a
certain class from the console appender.  I have two
appender's; a
console appender for ALL my classes and another
appender for a specific
package of classes.  This package provides scheduling
capabilities from
my app and writes to the console every 10 seconds.  I
would like to have
this package log to a RollingFileAppender ONLY and not
to the console
appender every 10 seconds.  Does anyone know how to
EXCLUDE a class from
being logged on a certain appender such as the CONSOLE
appender seen
below?  Any help is greatly appreciated.

 

CONSOLE:

  <appender name="CONSOLE"
class="org.apache.log4j.ConsoleAppender">

    <param name="Target" value="System.out"/>

            <!-- CHANGE "Value" to debug, info, warn,
etc...-->

    <param name="Threshold" value="info"/>

 

    <layout class="org.apache.log4j.PatternLayout">

      <!-- The default pattern: Date Priority
[Category] Message\n -->

      <param name="ConversionPattern"
value="%d{ABSOLUTE} %-5p [%c{1}]
%m%n"/>

    </layout>

  </appender>

 

 

RollingFileAppender:

 

              <appender name="UserDefined"
class="org.jboss.logging.appender.RollingFileAppender">

                        <param name="File"
value="${jboss.server.home.dir}/log/scheduler.log"/>

                        <param name="Append"
value="false"/>

                        <param name="MaxFileSize"
value="500KB"/>

                        <param name="MaxBackupIndex"
value="1"/>

 

                        <layout
class="org.apache.log4j.PatternLayout">

                          <param
name="ConversionPattern" value="%d %-5p
[%c] %m%n"/>

                        </layout>              

              </appender>

                        <category
name="com.shawmut.portal.scheduler">

                                    <priority
value="info"/>

                                    <appender-ref
ref="UserDefined"/>

                        </category>

 

 

Thanx

Russ

 


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


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

---------------------------------------------------------------------
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


Mime
View raw message