logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Boris Unckel <boris.unckel....@gmx.net>
Subject Re: multiple files
Date Fri, 30 Jun 2006 07:01:26 GMT
Hello Daniel,

Curt Arnold wrote:
>
> 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 approach.
There could be a workaround: The information about the logger name is
part of each log entry. You could easily write a script which splits
up one big log file into several others at your choice.
Why do you need that? You cannot see the flow of the application after
splitting the log.

This is the wrong list for this discussion. It belongs to log4-users.

Regards
Boris



Mime
View raw message