https://issues.apache.org/bugzilla/show_bug.cgi?id=53781
Priority: P2
Bug ID: 53781
Assignee: [email protected]
Summary: Need multiple logger instances in multithreaded
environment
Severity: normal
Classification: Unclassified
OS: Mac OS X 10.4
Reporter: [email protected]
Hardware: Macintosh
Status: NEW
Version: unspecified
Component: Other
Product: Log4j
I am using log4j in my testng project in a multithreaded environment.
I understand that log4j returns singleton instance of logger. However, in
multithreaded environment there is a need for multiple logger instances.
Here is the scenario
I have a following test class
class Test {
@BeforeMethod
public void writeToFile() {
//Set the appender
//Open a file abc.txt
log.info("Some message");
}
@AfterMethod
public void writeToFileAgain() {
//Open a file abc.txt
log.info("Some message again");
}
}
Now if the above test is run in multiple threads, the log messages get mixed up
in the file from different threads. The reason for this is the logger instance
is static and even if we have different file appenders the log files get mixed
up.
This is the reason why there is a need for multiple logger instances per
thread.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]