| Author |
Writing logs to a single file from Multiple Classes
|
ankuagar Ag
Greenhorn
Joined: Feb 11, 2011
Posts: 2
|
|
Hi,
I have created a CustomLogger class where I am adding file handler stuff to the default Logger. I want to use this logger into rest of my application.
When I am using this logger from two different classes, two log files are generated:
- ApplicationLog.log
- ApplicationLog.log.1
I want the logs to be written in a single file. Is this happening because of multiple threads? Please help.
Here is the Logger Code:
Calling Code (2 Different Class):
CustomLogger.getLogger().info("Dummy Message");
|
 |
ankuagar Ag
Greenhorn
Joined: Feb 11, 2011
Posts: 2
|
|
Got the error with my code.
Was instantiating a new instance of fileHandler every time getLogger is called. This creates a new file since previous file is locked with other handler.
Changed initialization of Logger to a different method and implemented Singleton on the CustomLogger.
|
 |
 |
|
|
subject: Writing logs to a single file from Multiple Classes
|
|
|