logging-log4j2 icon indicating copy to clipboard operation
logging-log4j2 copied to clipboard

Logs Cannot Be Written After VM File Handles Are Used Up

Open HaitaoDeng opened this issue 3 years ago • 2 comments

Description

Fault injection: VM file handles are used up, and logs cannot be printed after the fault is rectified. IOException: Stream Closed. [A clear and concise description of what the bug is.]

Configuration

Version: [Log4j version] 2.71.1 Operating system: [OS and version] linux JDK: [JDK distribution and version] openjdk 1.8

Logs

Logs during fault injection: image Logs After Fault Recovery: image

[Stacktraces, errors, etc. relevant applications logs.]

Reproduction

[An isolated test reproducing the test. JUnit tests similar to the ones in the code base are extremely appreciated.]

org.apache.logging.log4j.core.appender.rolling.RollingRandomAccessFileManager#writeToDestination randomAccessFile should check whether The Stream is closed。 image

HaitaoDeng avatar Feb 02 '23 12:02 HaitaoDeng

Once the file rollover fails the Appender is essentially dead as it no longer has an open stream. This is not unique to RandomAccessFile as all file appenders will face this. I really don't see a good way to fix this.

rgoers avatar Feb 09 '23 15:02 rgoers

Once the file rollover fails the Appender is essentially dead as it no longer has an open stream. This is not unique to RandomAccessFile as all file appenders will face this. I really don't see a good way to fix this.

IOException handling,when Stream Closed, randomAccessFile is set to null. A new access file will be created next time. Is this OK?

HaitaoDeng avatar Mar 14 '23 09:03 HaitaoDeng