aspose file tools
The moose likes Other Open Source Projects and the fly likes log4j - new instance for new class instance Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Reply Bookmark "log4j - new instance for new class instance" Watch "log4j - new instance for new class instance" New topic
Author

log4j - new instance for new class instance

Jim Cross
Greenhorn

Joined: Nov 20, 2003
Posts: 17
Hi all,

I am currently writing an application which takes a properties file listing the properties for an arbitrary set of "Adapter" objects. Each Adapter should log to its own log file, with the log file for each specified in the props file.

So, I might have 3 adapters - adapterA, adapterB and adapterC, which I want to log to adapterA.log, adapterB.log and adapterC.log.

The problem I have at the moment is that all instances of the Adapter class log to the same log file - the file specified in the last Adapter object to be instantiated.

The logger object in the Adapter class is non-static, and is initialised as follows:
private Logger log = Logger.getLogger(AdapterWrapper.class.getName());

(I have also tried this without the .getName() method, but it makes no difference).

In the constructor, the following call is made:
DOMConfigurator.configure(log4jFile)

where log4jFile is the name of the log4j file for that specific instance.


Any ideas why all instances share the same file, and any way to get around it?

Thanks,

Jim
 
 
subject: log4j - new instance for new class instance
 
Threads others viewed
log4j is printing only once at Start. unable to figure out the issue, please help
Issue with JBoss logging for different jboss instances running on same machine
Log4j and WSAD 5.0
Logs are not printig
Using java.util.logging.Logger in a multiThreaded application
developer file tools