Configuration of auditlog file

AuditLog file is created and filled with events by Logback logging framework. To configure log file location, size you need to modify file etc/logback.xml which contains following data:

<configuration scan="true">
	<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>logs/auditlogs/auditlog.log</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
		<!-- rollover hourly -->
			<fileNamePattern>logs/auditlogs/auditlog-%d{yyyy-MM-dd_HH}.%i.log.gz</fileNamePattern>
			<timeBasedFileNamingAndTriggeringPolicy
			class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
			<!-- or whenever the file size reaches 50MB -->
				<maxFileSize>50MB</maxFileSize>
			</timeBasedFileNamingAndTriggeringPolicy>
			<!-- No Limit -->
			<maxHistory>0</maxHistory>
		</rollingPolicy>
		<encoder>
			<charset>UTF-8</charset>
			<pattern>%msg%n</pattern>
		</encoder>
	</appender>

	<logger name="tigase.auditlog" level="trace"/>

	<root level="warn">
		<appender-ref ref="FILE"/>
	</root>
</configuration>

In this sample config it is set:

  • a template for a auditlog file name logs/auditlogs/auditlog-%d{yyyy-MM-dd_HH}.%i.log.gz
  • rolling logs to new files every 50MB and every day