I'm using log4j2, and running multiple instances of the same code in different processes (ie different JVMs) at the same time. I'd like all processes to log to the same file, interleaved How can I configure (via log4j2.xml) to output the PID, so that the different processes can be distinguished in the logs?
There is a plugin ProcessIdPatternConverter in log4j2-core since version 2.9 that does exactly this.
just setting %pid or %processId in the pattern layout logs it.
log4j documentation: https://logging.apache.org/log4j/2.x/manual/layouts.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With