-->

Logback slf4j cannot get log entries in log file

logback.xml

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

                                                  -->
<configuration>
<!-- Errors were reported during translation. -->
<!-- No root logger configuration was found -->

 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
        <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
        </Pattern>
    </layout>
</appender>


<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>c:\log\test.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%msg%n</pattern>
</encoder>
</appender>  

 <logger name="com.base22" level="DEBUG" />
<root level="debug">
    <appender-ref ref="STDOUT" />
    <appender-ref ref="FILE" /> 
</root>
 </configuration>

pom.xml dependencies

 <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>


 <dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.1</version>
</dependency>

 <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.26</version>
 </dependency>

  <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>0.9.26</version>
 </dependency>

 <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
<version>0.9.26</version>
 </dependency>

Using the above configurations for logback ..... Log statements are displayed on the console, but test.log is not created, and I can not find any logs even in the file after the file is created. I need to write any other configurations

+5
source share
1 answer

Your logback.xml does not fit where you are looking for it, so it quietly returns to the "print to console" configuration.

For more information on the configuration mechanism, see http://logback.qos.ch/manual/configuration.html .

+3
source

All Articles