Log4j2 create new log file if not exist

Viewed 1764

I am using RollingRandomAccessFile appende for log4j logging and everything is working fine ,

    <RollingRandomAccessFile name="xxx.FLT" fileName="${sys:xxx.log.path}FLT.log" filePattern="${sys:xxx.log.path}FLT.log.%i" append="true" immediateFlush="true" bufferSize="262144">
        <PatternLayout pattern="%d{MM-dd-yyyy HH:mm:ss,SSS} [%t] %level{WARN=WARNING, DEBUG=FINE, ERROR=SEVERE} %logger{36} - %convInfo %msg%n"/>
        <Policies>
            <SizeBasedTriggeringPolicy size="100MB"/>
        </Policies>
        <DefaultRolloverStrategy fileIndex="max" min="1" max="5" compressionLevel="3"/>
    </RollingRandomAccessFile>

At the application startup all the log files are created. I have an another process that remove log file from the disc if they are not getting update after some time.

if this process removed a log file, it will not create again at a new log event.

I want to create new log file if not exist in the given location at the time of new log event has been occurred

I know when the application restart missing files will be created again , but i want to create log file at the time of a log event occurred.

I am preferred to have a configuration level change other than a code level change.

1 Answers
Related