Hello!

We are using a RollingRandomAccessFile appender with a 5 minute cron
rollover schedule. On rare occasion logs stop being output after rolling
and seem to not recover until the application restarts.

We run with a somewhat complicated log configuration, using the following:
* Async appender
* Marker filters
* Name filters
* Multiple log files
* JSON output
* cron rollover schedule

We use log markers to filter our messages out to their own file. We use a
log name filter to filter a statistics class to its own file.

We run our application(s) daily and quite constantly, yet, the problem
seems to occur anywhere from multiple times a day to spanning a few days
between occurrences. When the problem does occur, it seems that it can be
corrected upon restarting the application.

Here is our log4j2.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Properties>
<Property name="cronRolloverSchedule">0 */5 * * * ?</Property>
<Property name="logDir">./logs</Property>
<Property name="rolloverLogDir">./logs_backup</Property>
<Property name="logPattern">%d{ISO8601}{UTC}Z %-5level [%thread] %logger -
%message%n</Property>
<Property name="messagePattern">%d{ISO8601}{UTC}Z %message%n</Property>
</Properties>
<Appenders>
<RollingRandomAccessFile
name="Main"
fileName="${logDir}/myapp.json.log"
filePattern="${rolloverLogDir}/myapp.json.log.%d{yyyy-MM-dd_HHmm}{UTC}Z">
<JsonLayout
properties="true"
complete="true" />
<Policies>
<CronTriggeringPolicy
schedule="${cronRolloverSchedule}"
evaluateOnStartup="true" />
</Policies>
</RollingRandomAccessFile>
<RollingRandomAccessFile
name="Statistics"
fileName="${logDir}/myapp.stats.json.log"
filePattern="${rolloverLogDir}/myapp.stats.json.log.%d{yyyy-MM-dd_HHmm}{UTC}Z">
<JsonLayout
properties="true"
complete="true" />
<Policies>
<CronTriggeringPolicy
schedule="${cronRolloverSchedule}"
evaluateOnStartup="true" />
</Policies>
</RollingRandomAccessFile>
<RollingRandomAccessFile
name="Message"
fileName="${logDir}/myapp-messages.json.log"
filePattern="${rolloverLogDir}/myapp-messages.json.log.%d{yyyy-MM-dd_HHmm}{UTC}Z">
<JsonLayout
properties="true"
complete="true" />
<Policies>
<CronTriggeringPolicy
schedule="${cronRolloverSchedule}"
evaluateOnStartup="true" />
</Policies>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<AsyncRoot level="trace">
<AppenderRef ref="Main">
<Filters>
<MarkerFilter
marker="MESSAGE"
onMatch="DENY"
onMismatch="NEUTRAL" />
<MarkerFilter
marker="EVENT_STATISTICS"
onMatch="DENY"
onMismatch="NEUTRAL" />
</Filters>
</AppenderRef>
<AppenderRef ref="Message">
<Filters>
<MarkerFilter
marker="MESSAGE"
onMatch="ACCEPT"
onMismatch="DENY" />
<MarkerFilter
marker="EVENT_STATISTICS"
onMatch="DENY"
onMismatch="NEUTRAL" />
</Filters>
</AppenderRef>
</AsyncRoot>
<AsyncLogger
name="com.myapp.EventStatistics"
level="INFO">
<AppenderRef ref="Statistics" />
</AsyncLogger>
</Loggers>
</Configuration>

Thanks for the help!

- Skye

Reply via email to