There is only one file. And it is written simultaneously as web app copies run.
How do you filter only one session log messages from other log lines?
You could set a context message including the identifier of the specific app instance using org.apache.log4j.NDC, like this:
String appInstanceId = "My App Instance 1";
org.apache.log4j.NDC.push(appInstanceId);
// handle request
org.apache.log4j.NDC.clear();
You can set up the context during the initialization of your web app instance, or inside the doPost()
method of your servlets. As its name implies, you can also nest contexts within contexts with multiple push
calls at different levels.
See the section "Nested Diagnostic Contexts" in the Log4J manual.