You could specify an alternative LoggerFactory to the logger hierarchy.  The 
factory would get called on the first request for a specific logger at which 
time would could attach appenders et al. 

If you are continuously adding directories, you could start exhausting 
resources since there is no reclamation of the appenders.  If that is the case, 
then it may be better to write a custom appender that choose the output file 
based on the logger name.  Unless you open and close the file per request, 
you'd still need to look at adding some intelligence to reclaim open files 
after a period of inactivity.


On Sep 7, 2010, at 3:42 PM, Chris wrote:

> How can I trap calls to Logger.getLogger() so I can configure each logger 
> dynamically?
> 
> Our app operates on data in dynamically-created directories. Every time we 
> see a new directory, we want to create a new logger to put the logs in a new 
> subdirectory. This means that we need a new logger instance for each 
> directory, which must have its own FileAppender with the appropriate 
> subdirectory name.
> 
> The trouble is that I can't configure all of these directory names in advance 
> in log4j.properties because I don't know what they will be.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to