java - How do I setup log4j properties so that each thread outputs to its own log file? -


I have several instances of thread classes that I have at any time to log in to log me to use log 4 Which is setup.

I need a way to setup log-46 so that each installation of my thread class can output logs to a different log file.

Here's what I did (in the phonetic code)

  The public class extends the doSomething thread {Private logger de_logger; Make public some (int id) {d_logger = logger.get logger ("doSomething" + id); String logfileName = "doSomething" + ID + ".log"; Properties PRO = new properties; Prop.setProperty ("doSomething" + id, "Debug, WORKLOG"); Prop.setProperty ("log4j.appender.WORKLOG", "org.apache.log4j.FileAppender"); Prop.setProperty ("log4j.appender.WORKLOG.File", logfile name); Prop.setProperty ("log4j.appender.WORKLOG.layout", "org.apache.log4j.PatternLayout"); Prop.setProperty ("log4j.appender.WORKLOG.layout.ConversionPattern", "% d% c {1} -% m% n"); Prop.setProperty ("log4j.appender.WORKLOG.Threshold", "info"); PropertyConfigurator.configure (support); } Public Zero Run () {d_logger.info ("start doing some numbers" + ID); }}  

However for each thread above, I create a file that I institute, it does not do anything out of those files. Any help is much appreciated.

This file is not output to anything because the correct syntax for setting logger is:

  prop.setProperty ("log4j.logger.do something" + id, "Dubai, VirtualGroup");  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -