Reputation: 159
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 above configurations for logback.....log statements are being displayed on console but test.log is not created and I dnt find any logs even in the file after me creating the file..do I need to write any other configurations
Upvotes: 5
Views: 6940
Reputation: 75426
Your logback.xml is not placed where logback looks for it, so it silently falls back to a "print to console" configuration.
See http://logback.qos.ch/manual/configuration.html for all the details about the configuration mechanism.
Upvotes: 3