Allow logging via SLF4J and logback-classic. Fixes #5

master v2.0.2
Brian Rosenberger 2023-09-28 10:49:47 +02:00
parent b2cd9fbda7
commit 6d85158246
3 changed files with 47 additions and 2 deletions

View File

@ -92,8 +92,9 @@ dependencies {
implementation "org.quartz-scheduler:quartz:2.3.2" implementation "org.quartz-scheduler:quartz:2.3.2"
implementation "org.slf4j:slf4j-api:2.0.7" implementation "org.slf4j:slf4j-api:2.0.7"
runtimeOnly "ch.qos.logback:logback-core:1.3.8"
runtimeOnly "org.slf4j:slf4j-simple:2.0.7" runtimeOnly "ch.qos.logback:logback-classic:1.3.8"
//runtimeOnly "org.slf4j:slf4j-simple:2.0.7"
implementation "org.apache.ws.commons.axiom:axiom:1.2.22" implementation "org.apache.ws.commons.axiom:axiom:1.2.22"
implementation "org.apache.ws.commons.axiom:axiom-impl:1.2.22" implementation "org.apache.ws.commons.axiom:axiom-impl:1.2.22"

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="XSERVICES-LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>../logs/XServices.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>XServices-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
<maxFileSize>100MB</maxFileSize>
<maxHistory>60</maxHistory>
<totalSizeCap>4GB</totalSizeCap>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.quartz" level="ERROR" />
<logger name="org.apache.shiro" level="ERROR" />
<logger name="net.brutex.xservices" additivity="false" level="INFO">
<appender-ref ref="XSERVICES-LOG" />
</logger>
<root level="WARN">
<appender-ref ref="STDOUT" /> <!-- This is usually captured by tomcat server.log -->
<appender-ref ref="XSERVICES-LOG" />
</root>
</configuration>

View File

@ -163,4 +163,14 @@
</security-constraint> </security-constraint>
--> -->
<servlet>
<servlet-name>ViewStatusMessages</servlet-name>
<servlet-class>ch.qos.logback.classic.ViewStatusMessagesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ViewStatusMessages</servlet-name>
<url-pattern>/logs</url-pattern>
</servlet-mapping>
</web-app> </web-app>