You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Eduardo Arantes Rodrigues <ed...@trgs.com.br> on 2008/12/03 14:37:02 UTC

runtime configurable file name appender

Hi,
 
I had a specific requirement that a certain set of similar Jobs should be
logged one individual file per Job.
That would make things easier to troubleshooting.
With the current FileAppenders implementation it would require a new
appender and category for each Job.
Since, so far, we have already 20 jobs it would be really painful to add and
maintain all of them and also the Jobs can be dynamically added to the
system.
That would break the rule of having one file per Jobs.
 
I've researched but I couldn't find an appender where the name of the file
to log could be configured dynamically.
 
Given this requirements my idea was provide a way to use PatternLayout like
file names.
 
This code allow the fileName to be defined as: "c:/temp/server[%-5p].log"
Depending on the pattern a new file can be generated by class, category or
even by day, hour, ...
 
I've used the FileAppender code as base
 
I've provide the JavaDoc for the most important methods.
 
I hope it's useful and can be added to the project
 
Regards,
Eduardo

RE: runtime configurable file name appender

Posted by Eduardo Arantes Rodrigues <ed...@trgs.com.br>.
That's the first draft.
If you have more features that would fit in here I'd be glade to add.

Just let me know. 

> -----Original Message-----
> From: Ceki Gulcu [mailto:ceki@qos.ch] 
> Sent: Wednesday, December 03, 2008 12:58 PM
> To: Log4J Developers List
> Subject: Re: runtime configurable file name appender
> 
> This is nicely related to the repository selector discussion, 
> Jake and I had on 30.11.2008. Well done.
> 
> Eduardo Arantes Rodrigues wrote:
> > Hi,
> >  
> > I had a specific requirement that a certain set of similar 
> Jobs should 
> > be logged one individual file per Job.
> > That would make things easier to troubleshooting.
> > With the current FileAppenders implementation it would 
> require a new 
> > appender and category for each Job.
> > Since, so far, we have already 20 jobs it would be really 
> painful to 
> > add and maintain all of them and also the Jobs can be dynamically 
> > added to the system.
> > That would break the rule of having one file per Jobs.
> >  
> > I've researched but I couldn't find an appender where the 
> name of the 
> > file to log could be configured dynamically.
> >  
> > Given this requirements my idea was provide a way to use 
> PatternLayout 
> > like file names.
> >  
> > This code allow the fileName to be defined as: 
> "c:/temp/server[%-5p].log"
> > Depending on the pattern a new file can be generated by class, 
> > category or even by day, hour, ...
> >  
> > I've used the FileAppender code as base
> >  
> > I've provide the JavaDoc for the most important methods.
> >  
> > I hope it's useful and can be added to the project
> >  
> > Regards,
> > Eduardo
> 
> --
> Ceki Gülcü
> Logback: The reliable, generic, fast and flexible logging 
> framework for Java.
> http://logback.qos.ch
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: runtime configurable file name appender

Posted by Ceki Gulcu <ce...@qos.ch>.
This is nicely related to the repository selector discussion, Jake and I had on 
30.11.2008. Well done.

Eduardo Arantes Rodrigues wrote:
> Hi,
>  
> I had a specific requirement that a certain set of similar Jobs should 
> be logged one individual file per Job.
> That would make things easier to troubleshooting.
> With the current FileAppenders implementation it would require a new 
> appender and category for each Job.
> Since, so far, we have already 20 jobs it would be really painful to add 
> and maintain all of them and also the Jobs can be dynamically added to 
> the system.
> That would break the rule of having one file per Jobs.
>  
> I've researched but I couldn't find an appender where the name of the 
> file to log could be configured dynamically.
>  
> Given this requirements my idea was provide a way to use PatternLayout 
> like file names.
>  
> This code allow the fileName to be defined as: "c:/temp/server[%-5p].log"
> Depending on the pattern a new file can be generated by class, category 
> or even by day, hour, ...
>  
> I've used the FileAppender code as base
>  
> I've provide the JavaDoc for the most important methods.
>  
> I hope it's useful and can be added to the project
>  
> Regards,
> Eduardo

-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org