Joel

Think of it this way.  You don't send log messages to Appenders, you send messages to 
Categories.  Your config file determines which appenders the categories use.  So, in 
your file you configured the rootCategory to use both LogFile and LogFile2.  When send 
a message to rootCategory it will go to both appenders.

You need to use two different categories if you want some messages to go to LogFile 
and others to LogFile2.

Let's say you have two classes:
com.abc.Joel
com.abc.Patthey

In the declaration for the classes you create Category instances like this:
// in Joel class
static Category LOG = Category.getInstance(Joel.class.getName());

// in Patthey class
static Category LOG = Category.getInstance(Patthey.class.get());

The config would look like this:

log4j.category.com.abc.Joel = DEBUG, LogFile
log4j.category.com.abc.Patthey = DEBUG, LogFile2


Log message from Joel go to LogFile and messages from Patthey go to LogFile2.


Hope that helps.

Jud Barr
Principal Financial Group
Des Moines, Iowa

[EMAIL PROTECTED]


-----Original Message-----
From: Joel Patthey [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 08, 2002 7:58 AM
To: Log4J Users List
Subject: RE: I am unable to log the messages to a file


I've tried a config file like this one and then I've added another
logger like this:

log4j.rootCategory = DEBUG, LogFile, LogFile2

log4j.appender.LogFile = org.apache.log4j.FileAppender
log4j.appender.LogFile2 = org.apache.log4j.FileAppender

log4j.appender.LogFile.layout = org.apache.log4j.PatternLayout
log4j.appender.LogFile.layout.ConversionPattern = %d{dd.MM.yyyy
HH:mm:ss} %-5p: [%m] -> %c%n
log4j.appender.LogFile2.layout = org.apache.log4j.PatternLayout
log4j.appender.LogFile2.layout.ConversionPattern = %d{dd.MM.yyyy
HH:mm:ss} %-5p: [%m] -> %c%n


log4j.appender.LogFile.File = C:\\Temp\\TestLog.log
log4j.appender.LogFile2.File = C:\\Temp\\TestLog2.log

but then, when I log to LogFile, it writes to both file and if I write
to LogFile2 it does the same. How do you setup N (i.e. more than 1)
independant logger in the same config file ?


-----Original Message-----
From: Nicole Grübel [mailto:[EMAIL PROTECTED]]
Sent: vendredi, 8. mars 2002 14:48
To: [EMAIL PROTECTED]
Subject: Re: I am unable to log the messages to a file


I'm not sure if this is helpful, but this way I told my Config-File to
log messages to a file. It's nearly the same when you use XML and it
might give you an idea what you should implement in your source-code if
you don't use a configuration file.

log4j.rootCategory = DEBUG, LogFile

log4j.appender.LogFile = org.apache.log4j.FileAppender

log4j.appender.LogFile.layout = org.apache.log4j.PatternLayout
log4j.appender.LogFile.layout.ConversionPattern = %d{dd.MM.yyyy
HH:mm:ss} %-5p: [%m] -> %c%n

log4j.appender.LogFile.File = C:\\Temp\\TestLog.log


I hope this helps. 

Nicole 
________________________________________________________________
Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr! 
Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13



--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to