You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Edward L. Knoll" <ed...@cosd.fedex.com> on 2006/09/14 22:45:07 UTC
Separate log files per thread.
We want to set up or log4j configuration with thread specific log files.
I've been through many archives and have seen several suggestions, but
I'm still looking for a solution better aligned to our needs. I'll
summarize the solutions I've already stumbled across in case there was
something I overlooked. If you have suggestions, please provide a
little bit of detail or references to same.
1) Don't do it. Add some kind of content to the message (e.g. thread
name in the conversion pattern, output context added via the NDC or MDC
classes). Filter the single log file everything is logged to as a
post-processing exercise. Might work for one of our situations.
2) Define multiple appenders in the configuration file and create the
loggers by name. Might work in some of our situations where the
threading configuration is static or predictable (and small).
3) Did see an older reference to something referred to as a 'context
sensitive appender' which someone had provided code for. This was
promising, because a simple context-sensitive configuration definition
would cover multiple loggers/appenders/files. Unfortunately, I was
unable to unzip the attached zip file and the author references had been
sanitized (and likely too old to be valid anyway).
Re: Separate log files per thread.
Posted by Curt Arnold <ca...@apache.org>.
On Sep 14, 2006, at 4:11 PM, James Stauffer wrote:
> 4. Write your own appender that potentially changes the logfile name
> per logging event. I do a smiliar thing with an appender.
> http://stauffer.james.googlepages.com/DateFormatFileAppender.java
>
5. Discuss the requirements for such an appender on the mailing list
and see if a consensus could be formed. If so, a sandbox project
could be started to develop the appender and when functional it might
get added into log4j itself. You also might check if log4net might
already have something similar and if so, we might port it back from
there.
I thought about it a little. It was thinking that you might specify
a java.text.MessageFormat pattern for file name using Thread.getName
() (or Thread.toString() if name was blank), the maximum number of
open files, plus the WriterAppender properties. The appender would
keep a hashmap of Writers keyed by the generated file name and would
maintain it so it closed the stalest Writer if the open file count
would have been exceeded.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Separate log files per thread.
Posted by James Stauffer <st...@gmail.com>.
4. Write your own appender that potentially changes the logfile name
per logging event. I do a smiliar thing with an appender.
http://stauffer.james.googlepages.com/DateFormatFileAppender.java
On 9/14/06, Edward L. Knoll <ed...@cosd.fedex.com> wrote:
> We want to set up or log4j configuration with thread specific log files.
> I've been through many archives and have seen several suggestions, but
> I'm still looking for a solution better aligned to our needs. I'll
> summarize the solutions I've already stumbled across in case there was
> something I overlooked. If you have suggestions, please provide a
> little bit of detail or references to same.
>
> 1) Don't do it. Add some kind of content to the message (e.g. thread
> name in the conversion pattern, output context added via the NDC or MDC
> classes). Filter the single log file everything is logged to as a
> post-processing exercise. Might work for one of our situations.
>
> 2) Define multiple appenders in the configuration file and create the
> loggers by name. Might work in some of our situations where the
> threading configuration is static or predictable (and small).
>
> 3) Did see an older reference to something referred to as a 'context
> sensitive appender' which someone had provided code for. This was
> promising, because a simple context-sensitive configuration definition
> would cover multiple loggers/appenders/files. Unfortunately, I was
> unable to unzip the attached zip file and the author references had been
> sanitized (and likely too old to be valid anyway).
>
>
>
--
James Stauffer http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org