NopeCharon opened a new issue, #828: URL: https://github.com/apache/logging-log4cxx/issues/828
`PatternLayout` has no conversion word for the operating system process identifier, so there is no way to tell which process wrote a logging event. This matters most when several processes log to the same file, which the [multiple process logging page](https://logging.apache.org/log4cxx/latest_stable/multiprocess.html) describes as supported (and `MultiprocessRollingFileAppender` exists for). The thread identifier (`%t`) is only unique within a process, so lines from different processes cannot be told apart. The only workaround is for every application to put its own process id into the MDC or into a configuration variable before configuring Log4cxx, and that does not give the right value in a child process created by `fork()`. Log4j 2 provides this as `%pid` / `%processId` in its PatternLayout. There is also a small trap today: because `PatternParser` falls back to the longest known prefix, a pattern containing `%pid` is silently accepted and outputs the level followed by the text `id` (e.g. `INFOid`). Proposal: add a `ProcessIdPatternConverter` registered in `PatternLayout` as `pid` and `processId`, which outputs the current process identifier (`getpid()` on POSIX, `GetCurrentProcessId()` on Windows). The value would be read when the event is formatted, so a forked child process outputs its own identifier. For example: ```properties log4j.appender.A1.layout.ConversionPattern=%d [%pid:%t] %-5p %c - %m%n ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
