You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Patrick-Harms (via GitHub)" <gi...@apache.org> on 2025/01/02 12:57:15 UTC
[I] Concurreny issues with RollingFileAppender (logging-log4j2)
Patrick-Harms opened a new issue, #3352:
URL: https://github.com/apache/logging-log4j2/issues/3352
I have a server application that consists of many separate processes (sometimes 20+) that use Log4J2 for logging and based on the number need to log to a central Log4J2 rolling file appender. A rolling file appender, as per usual is needed, to keep on top of disc space consumed by logging.
The "out of the box" Log4J2 rolling file appender has concurrency issues, when multiple processes (and I have caused issues with just two instances).
The issue, at initial investigation, is that all the processes want to be Master, and roll the file. That causes an error, and on the next log message, the process then gets a hard error that the stream is closed.
Does anyone know of a configuration sharing the same destination log file?
Or do I need to write my own custom appender to handle concurrency issues?
--
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: notifications-unsubscribe@logging.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Concurrency issues with Log4J2 Rolling File Appender (logging-log4j2)
Posted by "Patrick-Harms (via GitHub)" <gi...@apache.org>.
Patrick-Harms closed issue #3352: Concurrency issues with Log4J2 Rolling File Appender
URL: https://github.com/apache/logging-log4j2/issues/3352
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Concurrency issues with Log4J2 Rolling File Appender (logging-log4j2)
Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #3352:
URL: https://github.com/apache/logging-log4j2/issues/3352#issuecomment-2569233815
@Patrick-Harms,
> The issue, at initial investigation, is that all the processes want to be Master, and roll the file. That causes an error, and on the next log message, the process then gets a hard error that the stream is closed.
The rolling file appender does not support logging to the same file from **separate** JVMs, because there is no reliable mechanism in Java to decide which process will be the "primary" process, i.e. will actually perform the rotation. The same log file can only be reused by multiple applications in the same **application server** (see [note on `RollingFileManager` sharing](https://logging.apache.org/log4j/2.x/manual/appenders/rolling-file.html#appenders)).
Even if you solve the problem of files being rotated multiple times, other features of the rolling file appender will still not work with multiple JVMs: e.g. the [`SizeBasedTriggeringPolicy`](https://logging.apache.org/log4j/2.x/manual/appenders/rolling-file.html#SizeBasedTriggeringPolicy) will not take into account the logs from other JVMs to determine the current size of the log file.
As mentioned by @swebb2066, if you want to use the same files in multiple applications, you should forward all the logs to an external application, like the mentioned [Fluent Bit](https://fluentbit.io/), [Fluentd](https://www.fluentd.org/) or the common [RSyslog](https://www.rsyslog.com/). Note that Log4j Core has specialized [RFC 5424](https://logging.apache.org/log4j/2.x/manual/layouts.html#RFC5424Layout) and [RFC 3164 layouts](https://logging.apache.org/log4j/2.x/manual/layouts.html#SyslogLayout) to format log events in a way recognized by Syslog. You can combine them with a file or [socket appender](https://logging.apache.org/log4j/2.x/manual/appenders/network.html#SocketAppender) to send messages to RSyslog.
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Concurrency issues with Log4J2 Rolling File Appender (logging-log4j2)
Posted by "swebb2066 (via GitHub)" <gi...@apache.org>.
swebb2066 commented on issue #3352:
URL: https://github.com/apache/logging-log4j2/issues/3352#issuecomment-2568637020
Have you considered sending logging events to the [TCP input plugin of a fluent-bit log server](https://docs.fluentbit.io/manual/pipeline/inputs/tcp)](https://docs.fluentbit.io/manual/pipeline/inputs/tcp)?
I have observed [in Log4cxx](https://github.com/apache/logging-log4cxx/pull/443) that coordinating the rollover of the file adds a large overhead (4 and 10 times on Linux and Windows respectively) to each logging request
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Concurrency issues with Log4J2 Rolling File Appender (logging-log4j2)
Posted by "Patrick-Harms (via GitHub)" <gi...@apache.org>.
Patrick-Harms commented on issue #3352:
URL: https://github.com/apache/logging-log4j2/issues/3352#issuecomment-2569892166
Thanks @swebb2066 and @ppkarwasz for your knowledgeable replies👍. I will investigate your suggested approaches of forwarding all events to an external application using a SocketAppender. 👍
--
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: notifications-unsubscribe@logging.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org