Reputation: 905
I have log4cxx implementation in utility.dll. This dll is used by application1.dll and application2.dll
Application1 defines log file name as "c:\application1\applog.log"; Application2 defines log file name as "c:\application2\applog.log".
If I run both the applications seperately, logs are created in the corresponding files properly. If I try to run both the applications simultaneously the logs are created in latest opened application's log file.
I have opened application1 first logs are created in "application1\applog.log" file. At same time I opened Application2. Now both application's logs are appended in "application2\applog.log"
Note: Both of my applications are dlls acting like a drivers) Both are acting as a seperate application I need logs to be in different output files. Both dlls will run under same exe.
How to make the the same log4cxx implementation to log in different log files per application?
Upvotes: 2
Views: 1365
Reputation: 2241
I had a similar situation where my app and dll were logging to the same file. This is just an educated guess, but try changing the name of the logger in the dlls and app.
// in application1.dll
const log4cxx::LoggerPtr logger1 log4cxx::Logger::getLogger("ABC"));
log4cxx::PropertyConfigurator::configure("./application1.config");
// in application2.dll
const log4cxx::LoggerPtr logger2 log4cxx::Logger::getLogger("ABC"));
log4cxx::PropertyConfigurator::configure("./application2.config");
Assuming you are using a canned configuration. applicagtion1.config and application2.config could be identical except for the log4j.appender.File.File=
line
in application1.config
log4j.appender.File.File=logs/application1.logs
and in application2.config
log4j.appender.File.File=logs/application2.logs
Upvotes: 1