I have a Client and Server class. There is one Client instance running and eight Server instances running at the same time in the same JVM.
I now wish to (programatically or through properties file) setup log4j so that I’d have one log file per class instance. For the example above I’d like to have 9 separate log files.
If you are using the same Logger for all the instances (v.g.,
private static final Logger log = Logger.getLogger(MyClass.class), all logs will follow the same process.You should define the logger as an instance attribute and setup a different behavior for each one in the log4j.properties, v.g.