Skip to main content Skip to complementary content

Syncope log rotation

Define the rotation policy in $IAM_HOME/apache-tomcat/webapps/<app>/WEB-INF/classes/log4j2.xml.

For information about this Syncope log rotation appender, see the Apache documentation: https://logging.apache.org/log4j/2.x/manual/appenders.html

Procedure

  1. Open $IAM_HOME/apache-tomcat/webapps/<app>/WEB-INF/classes/log4j2.xml and find the appender used to define the log rotation strategy. This appender could look like:

    Example

    <appenders>
        <RollingRandomAccessFile name="main" fileName="${sys:catalina.base}/logs/enduser.log"
                                 filePattern="${sys:catalina.base}/logs/enduser-%d{yyyy-MM-dd}.log.gz"
                                 immediateFlush="false" append="true">
             <PatternLayout>
                <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
             </PatternLayout>
             <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="250 MB"/>
             </Policies>
        </RollingRandomAccessFile>
    </appenders>
    This default configuration means rotation takes place every day and the total file size is limited to 250 MB.
  2. If you need to add an automatic cleanup policy, add a roller strategy to the RollingRandomAccessFile appender. For example:

    Example

    <appenders>
        <RollingRandomAccessFile name="main" fileName="${sys:catalina.base}/logs/enduser.log"
                                 filePattern="${sys:catalina.base}/logs/enduser-%d{yyyy-MM-dd}.log.gz"
                                 immediateFlush="false" append="true">
             <PatternLayout>
                <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
             </PatternLayout>
             <Policies>
                <TimeBasedTriggeringPolicy/>
                <SizeBasedTriggeringPolicy size="250 MB"/>
             </Policies>
             <DefaultRolloverStrategy max="100">
               <Delete basePath="${baseDir}" maxDepth="2">
                  <IfFileName glob="*/app-*.log.gz">
                     <IfLastModified age="30d">
                       <IfAny>
                        <IfAccumulatedFileSize exceeds="100 GB" />
                        <IfAccumulatedFileCount exceeds="10" />
                       </IfAny>
                     </IfLastModified>
                  </IfFileName>
                </Delete>
             </DefaultRolloverStrategy>
        </RollingRandomAccessFile>
    </appenders>
    
    Information noteNote: The Syncope application uses Log4J 2 to manage its log levels. Those levels could be
    • OFF
    • FATAL
    • ERROR
    • WARN
    • INFO
    • DEBUG
    • TRACE
    • ALL
    For further information about these levels, see the documentation from Apache Log4J: Apache Log4J 2 custom logging levels.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!