By assigning an appender to a priority level, could I also do this so that I
could send messages of INFO priority to a file appender while seperating
messages of ERROR priority to an SMTP appender?

Using the following properties file, I want messages for category
com.mycorp.employee to log to the EMP_Appender when the priority is INFO,
WARN and ERROR but also send the ERROR messages to an SMTP_Appender.

What I would like to accomplish is for each department to have an individual
log file for general messages but have a copy of ERROR messages sent to an
SMTP so that a page can be generated. Following the heirarchy, INFO,WARN and
ERROR messages would also be logged to MyCorp_Appender whereas there would
be a log file for INFO - ERROR messages for the entire company. This would
be useful for an administration group to track statistics for example.

# ******************************************* Begin log4j.properties
*********************************************
log4j.rootCategory=INFO, Root_Appender
log4j.appender.Root_Appender=org.apache.log4j.FileAppender
log4j.appender.Root_Appender.File=E:/dev/log4j/Root.log
log4j.appender.Root_Appender.Location=true
log4j.appender.Root_Appender.layout=org.apache.log4j.PatternLayout
log4j.appender.Root_Appender.layout.ConversionPattern=%d{yyyy-MM-dd
HH:mm:SS} [%t] %-5p %c %x [%c.%F.%M:%L] - %m%n

log4j.category.com.mycorp=INFO, MyCorp_Appender
log4j.appender.MyCorp_Appender=org.apache.log4j.FileAppender
log4j.appender.MyCorp_Appender.File=E:/dev/log4j/NSCorp.log
log4j.appender.MyCorp_Appender.Location=true
log4j.appender.MyCorp_Appender.layout=org.apache.log4j.PatternLayout
log4j.appender.MyCorp_Appender.layout.ConversionPattern=%d{yyyy-MM-dd
HH:mm:SS} [%t] %-5p %c %x [%c.%F.%M:%L] - %m%n

log4j.category.com.mycorp.employee=INFO, EMP_Appender
log4j.appender.EMP_Appender=org.apache.log4j.FileAppender
log4j.appender.EMP_Appender.File=E:/dev/log4j/EMP.log
log4j.appender.EMP_Appender.Location=true
log4j.appender.EMP_Appender.layout=org.apache.log4j.PatternLayout
log4j.appender.EMP_Appender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:SS}
[%t] %-5p %c %x [%c.%F.%M:%L] - %m%n

log4j.category.com.mycorp.employee=ERROR, SMTP_Appender
log4j.appender.SMTP_Appender=org.apache.log4j.net.SMTPAppender
[EMAIL PROTECTED]
[EMAIL PROTECTED]
log4j.appender.SMTP_Appender.Subject=Fatal ERROR Encountered
log4j.appender.SMTP_Appender.SMTPHost=mailhub.mycorp.com
log4j.appender.SMTP_Appender.Location=true
log4j.appender.SMTP_Appender.layout=org.apache.log4j.PatternLayout
log4j.appender.SMTP_Appender.layout.ConversionPattern=%d{yyyy-MM-dd
HH:mm:SS} [%t] %-5p %c %x [%c.%F.%M:%L] - %m%n

log4j.category.com.mycorp.finance=DEBUG, FIN_Appender
log4j.appender.FIN_Appender=org.apache.log4j.FileAppender
log4j.appender.FIN_Appender.File=E:/dev/log4j/FIN.log
log4j.appender.FIN_Appender.Location=true
log4j.appender.FIN_Appender.layout=org.apache.log4j.PatternLayout
log4j.appender.FIN_Appender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:SS}
[%t] %-5p %c %x [%c.%F.%M:%L] - %m%n
# ******************************************* End log4j.properties
************************************************

-----Original Message-----
From: Ceki Gülcü [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 26, 2001 2:43 PM
To: LOG4J Users Mailing List
Subject: Re: different patterns for different PRIORITY levels



Anuj,

Sure. You need to assign an appender to a priority level and configure each
appender with a different layout. Ceki

At 14:30 26.03.2001 -0500, Anuj Agrawal wrote:
>REPOST:
>
>Is it possible to setup different output patterns for different log
messages
>with
>different priority levels?
>
>E.g. I want ERROR logs to have a date/time stamp and line numbers, but not
DEBUG
>logs.
>
>Is that possible?
>Anuj.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


I hope to see you at my ApacheCon 2001 presentation
entitled "Log4j, A Logging Package for Java".

See http://ApacheCon.Com/2001/US/ for more details.

--
Ceki Gülcü          Web: http://qos.ch
                email: [EMAIL PROTECTED] (preferred)
                         [EMAIL PROTECTED]


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

Reply via email to