Hi Rhys,
Thanks anyway.

For the record, here's the equivalent question asked for log4j in general:
http://stackoverflow.com/questions/17399610/log4j-set-different-layout-for-same-file

regards,
Lars R.

-----Original Message-----
From: Rhys Ulerich [mailto:rhys.uler...@gmail.com] 
Sent: mercredi 22 janvier 2014 00:44
To: Log4CXX User
Subject: Re: Different loggers writing to same file with different Layouts?

> I'd like to have two different loggers logging to a same file, but with 
> different Layouts.

I suspect, but do not know, that this is not supported.

> I have created two different loggers, part of same hierarchy.
> Naively, I have assigned a different FileAppender to each, with a different 
> Layout each.
> But I have given the same file name to both.
> This works. Both types of logs appear in the file.
>
> However i wonder if this is only a side-effect rather than a feature.

I believe you're right that it is only a side-effect of the implementation.

> Because what would happen if i set different options on the two FileAppenders?
> What if i use both RollingFileAppender and FileAppender on the same file?

I suspect Very Bad Things (TM).

> So is there another (safer?) recommended method for having two loggers 
> writing to the same file, but with different layouts?

I'm unsure of one.  I believe a Layout is 1-1 with an Appender and a File is 
1-1 with a FileAppender.  How to do this is not jumping out at me from browsing 
the class hierarchy.

Sorry to not be more help,
Rhys

Reply via email to