added new parameter "disable-file-logging" to disable logging to file.

This commit is contained in:
Heavenfighter
2023-09-06 10:17:42 +02:00
parent 4fe7c4bcee
commit e961564a02
2 changed files with 46 additions and 34 deletions

View File

@@ -1,37 +1,38 @@
<configuration>
<appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
<target>System.err</target>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<configuration>
<if condition='!isDefined("disable-file-logging")'>
<then>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- Daily rollover -->
<fileNamePattern>log/ZUV-%d{yyyy-MM}.log</fileNamePattern>
<!-- Keep 5 years worth of history -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
<target>System.err</target>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
</then>
</if>
</appender>
<!-- Configure so that it outputs to both console and log file -->
<root level="INFO">
<if condition='!isDefined("disable-file-logging")'>
<then>
<appender-ref ref="FILE" />
</then>
<if condition='property("FILE_APPENDER_ENABLED").contains("true")'>
<then>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender" >
<!--<appender name="FILE" class="org.mustangproject.commandline.LazyRollingFileAppender" >-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- Daily rollover -->
<fileNamePattern>log/ZUV-%d{yyyy-MM}.log</fileNamePattern>
<!-- Keep 5 years worth of history -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
</then>
</if>
<appender-ref ref="STDERR" />
</root>
<!-- Configure so that it outputs to both console and log file -->
<root level="INFO">
<if condition='property("FILE_APPENDER_ENABLED").contains("true")'>
<then>
<appender-ref ref="FILE" />
</then>
</if>
<appender-ref ref="STDERR" />
</root>
</configuration>