logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: multiple files
Date Thu, 29 Jun 2006 19:02:42 GMT

On Jun 29, 2006, at 11:03 AM, Daniel Carvalho wrote:

> Hi.
> i would like to have log4j configured so that each logger is  
> appended to a different file.
> The filename would be based on logger's name, with dots replaced by  
> file-separator. For instance, the logger named "aplic.dada.x1"  
> would go to
> "/MYLOGDIR/aplic/dada/x1.log"
> It would be nice to have an appender "FileTreeAppender" with this  
> funcionality. Then i would configure the root logger to use this  
> appender.
> Acorddingly to log4j rules, all other loggers would inherit this  
> appender.
> But this wouldn't work, because all loggers would use the same  
> instance of FileTreeAppender, but i want their outputs to go to  
> different files. One
> solution would be the "FileTreeAppender.doAppend" method choose the  
> file based in LoggingEvent.getLoggerName(), but this would be very  
> slow.

All you would be adding is a get() on a hash map to map logger name  
with to get an OutputStream for each call to doAppend.  The cost of  
mapping logger name to stream will be trivial compared to actual file  
io.  You would end up having an open OutputStream around for every  
encountered log name until the end of the appenders lifetime, but I  
don't know if you had a chance to work around that in any other  

View raw message