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 sudhakardvvn <dv...@yahoo.com> on 2006/10/11 13:48:52 UTC

logging into different files

Have an application where the number of threads that get launched are
dynamic.  Could be anywhere from 1 to 300 threads that could get launched at
runtime.  I would like to know if it is possible to setup a file appender
for each thread and have the indiv threads write to their own file appender. 
Currently all threads write to one log file using 1 file appender in a
log4j.properties file but would like ability for each thread to log its own
messages for easier debugging. Any good sites or source would be great. Any
help would be appreciated.  

-- 
View this message in context: http://www.nabble.com/logging-into-different-files-tf2422885.html#a6754850
Sent from the Log4j - Users mailing list archive at Nabble.com.


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


Re: logging into different files

Posted by James Stauffer <st...@gmail.com>.
That should be possible by writing your own appender.  Search the
archives as this was discussed recently.

On 10/11/06, sudhakardvvn <dv...@yahoo.com> wrote:
>
> Have an application where the number of threads that get launched are
> dynamic.  Could be anywhere from 1 to 300 threads that could get launched at
> runtime.  I would like to know if it is possible to setup a file appender
> for each thread and have the indiv threads write to their own file appender.
> Currently all threads write to one log file using 1 file appender in a
> log4j.properties file but would like ability for each thread to log its own
> messages for easier debugging. Any good sites or source would be great. Any
> help would be appreciated.
>
> --
> View this message in context: http://www.nabble.com/logging-into-different-files-tf2422885.html#a6754850
> Sent from the Log4j - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
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


Re: logging into different files

Posted by Michael Giroux <ml...@gmail.com>.
I think that you could use something like:

 PatternLayout pattern = new PatternLayout("your pattern");
 String filename = <some file name based on thread name>;
 FileAppender  threadAppender = new FileAppender(pattern, filename);
 String threadLogName = <some log name derived from thread name>;
 Logger threadLog = Logger.getLogger(threadLogName);
 threadLog.setAdditivity(false);
 threadLog.addAppender(threadLog);

Michael Giroux

On 10/11/06, sudhakardvvn <dv...@yahoo.com> wrote:
>
> Have an application where the number of threads that get launched are
> dynamic.  Could be anywhere from 1 to 300 threads that could get launched at
> runtime.  I would like to know if it is possible to setup a file appender
> for each thread and have the indiv threads write to their own file appender.
> Currently all threads write to one log file using 1 file appender in a
> log4j.properties file but would like ability for each thread to log its own
> messages for easier debugging. Any good sites or source would be great. Any
> help would be appreciated.
>
> --
> View this message in context: http://www.nabble.com/logging-into-different-files-tf2422885.html#a6754850
> Sent from the Log4j - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

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