Log files created, activity seen during the day, upon rolling, named file exists but is 0 bytes

43 Views Asked by At

Seeing an issue using Log4j2 where the log file during application activity is named as: <service-name>.log ... and this file reflects current messages being logged throughout the day.

Example: Process100Server.log is reflecting CURRENT activity. At 23:59 each night, that active log file content is supposed to be reflected in that day's file which will be rolled and named, (say on the day, 09-24-2023):

Process100Server.log-2023-09-24.log

The "active" logging for the next day then goes back to a fresh log, starting all over again.

Process100Server.log

When the named file is created, somehow the expected content from Process100Server.log is LOST and all we see is an empty file w/ the date stamp

-rw-r--r-- 1 abcadmin abcadmin 0 Sep 25 23:59 Process100Server.log-2023-09-24.log

In fact, a few days of this and we see rolled (date-stamped) files that are ZERO bytes:

-rw-r--r-- 1 abcadmin abcadmin 2346943 Sep 27 15:56 Process100Server.log
-rw-r--r-- 1 abcadmin abcadmin 0 Sep 24 23:59 Process100Server.log-2023-09-24.log
-rw-r--r-- 1 abcadmin abcadmin 0 Sep 25 23:59 Process100Server.log-2023-09-25.log
-rw-r--r-- 1 abcadmin abcadmin 0 Sep 26 23:59 Process100Server.log-2023-09-26.log

In summary, only the NON-date-stamped files show any content...Once the file is date stamped, its content is gone. At a loss with this. Any insight is appreciated.

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn">
  <Appenders>

    <RollingFile name="RollingFile"
                 fileName="/apps/servers/process/logs/Process100Server.log"
                 filePattern="logs/Process100Server.log-%d{yyyy-MM-dd}.log" >
      <PatternLayout>
        <pattern>%d{ABSOLUTE} %5p [%t]%c{1}:%L - %m%n</pattern>
      </PatternLayout>
      <Policies>
        <TimeBasedTriggeringPolicy interval="1" modulate="true" />
      </Policies>
    </RollingFile>

    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d %-5p:[%t]%c{1} -%m%n"/>
    </Console>

  </Appenders>

  <loggers>


    <root level="info">
      <appender-ref ref="RollingFile" level="info"/>
    </root>

  </loggers>

</Configuration>

Tried changing the Appender type and file name pattern... no effect.

Log4J2 version: 2.17.0

0

There are 0 best solutions below