-----邮件原件-----
发件人: Javier Gonzalez [mailto:[EMAIL PROTECTED] 
发送时间: 2006年8月10日 12:31
收件人: Log4J Users List
主题: Re: One question about extending log4j

On 8/9/06, 吕晓一 <[EMAIL PROTECTED]> 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


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

Reply via email to