logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kumar, Neeraj X \(Credit\)" <Neeraj.X.Ku...@gs.com>
Subject RE: One question about extending log4j
Date Thu, 10 Aug 2006 11:51:02 GMT
Hi 
I have extended the Rolling file appender to create separate files per thread.
Attached is the implementation.
For this you need to set up the log4j as

log4j.appender.GetAccountInfo=com.gs.eq.pb.commodore.logger.ExtendedRollingFileAppender
log4j.appender.GetAccountInfo.File=logs/GetAccountInfo.log
log4j.appender.GetAccountInfo.layout=org.apache.log4j.PatternLayout
log4j.appender.GetAccountInfo.layout.ConversionPattern=%d{ABSOLUTE} %5p %C{1}:%L - %m%n
log4j.logger.GetAccountInfo.additivity=true
log4j.appender.GetAccountInfo.MaxFileSize=1KB
log4j.appender.GetAccountInfo.MaxBackupIndex=3
log4j.logger.GetAccountInfo=debug, GetAccountInfo

Regards
Neeraj

-----Original Message-----
From: Javier Gonzalez [mailto:jagonzal@gmail.com] 
Sent: Thursday, August 10, 2006 5:31 AM
To: Log4J Users List
Subject: Re: One question about extending log4j

On 8/9/06, 吕晓一 <lvxiaoyi@aspire-tech.com> wrote:
> Hi all,
>
> I encountered a problem in my requirement.
>
> Several threads will write different type Value Object to an Object Queue,
> and one Log thread will consume these VO in the Queue, and the Log thread is
> extended from log4J, it will write the VO's value to different log files
> according to the VO's type.
>
> So, what should I do? Could anybody give me a solution?

For each VO, log to a different logger, named after the type of the
VO. For example:

// receive VO
ValueObject vo = getFromQueue();
Logger log = Logger.getLogger(vo.getType());
log.log(whatever you wish to log);

And then, in the log4j configuration file, create an different
appender for each VO Type. Attach those appenders to the loggers named
after the VO Types.

-- 
Javier González Nicolini


Mime
View raw message