Openfire 4.7: Log stays empty when using a "time based" policy in log4j2

Hi,

I tried to switch the openfire.log from SizeBasedTriggeringPolicy to TimeBasedTriggeringPolicy for a daily rotation and keep 7 days, but afterwards openfire does not write anything into the log file anymore. I tested with the current deb. package and versions 4.7.3 and 4.7.4. I also tested a seperate log file, but the same issue here.

    <RollingFile name="openfire" fileName="${sys:openfireHome}/logs/openfire.log" filePattern="${sys:openfireHome}/logs/openfire.log-%i">
        <PatternLayout>
            <Pattern>%d{yyyy.MM.dd HH:mm:ss} %highlight{%-5p} [%t]: %c - %msg{nolookups}%n</Pattern>
        </PatternLayout>
        <Policies>
            <TimeBasedTriggeringPolicy interval="86400"/>
            <DefaultRolloverStrategy max="7"/>
        </Policies>
    </RollingFile>

Best regards
Daniel

I think that has a couple of errors in the configuration: no date stamp in the file name pattern, the roll-over strategy isn’t a policy, I think, and I don’t think that the interval parameter on the TimeBasedTriggeringPolicy works in the way you think it does.

Try something like the following. I have not tested if this actually rolls over every day, but it starts logging:

<?xml version="1.0" encoding="UTF-8"?>

<Configuration monitorInterval="30">
    <Appenders>

        <RollingFile name="openfire" fileName="${sys:openfireHome}/logs/openfire.log" filePattern="${sys:openfireHome}/logs/openfire.log-%d{yyyy-MM-dd}">
            <PatternLayout>
                <Pattern>%d{yyyy.MM.dd HH:mm:ss} %highlight{%-5p} [%t]: %c - %msg{nolookups}%n</Pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy />
            </Policies>
            <DefaultRolloverStrategy max="7"/>
        </RollingFile>

        <Console name="console" target="SYSTEM_OUT">
            <PatternLayout pattern="%msg{nolookups}%n%throwable{0}"/>
        </Console>
        
    </Appenders>

    <Loggers>
        <!-- OF-1095: Uniform output of loading/unloading of plugins to std-out. -->
        <Logger name="org.jivesoftware.openfire.container.PluginManager">
            <AppenderRef ref="console"/>
        </Logger>
        <Logger name="org.jivesoftware.openfire.container.PluginMonitor">
            <AppenderRef ref="console"/>
        </Logger>

        <!-- OF-506: Jetty INFO messages are generally not useful. Ignore them by default. -->
        <Logger name="org.eclipse.jetty" level="warn"/>

        <Root level="info">
            <AppenderRef ref="openfire"/>
        </Root>
    </Loggers>
</Configuration>
1 Like

Thanks a lot for your help and clarification. The missing pattern was the main issue, I was falsely focused on the PatternLayout all the time :-/ And you are correct, rolloverStrategy is not a policy. I fixed this accordingly and it now logs again… I will keep an eye on the roll over mechanism itself over the next days. Thanks again!
Daniel

1 Like