Reputation: 6872
I have a eclipse maven project in which I am trying to use logback.xml
. But the logback.xml
is not getting picked. I have gone through this link and have verified that logback.xml
is placed in src/main/resources/
& it is in my classpath.
My logback.xml
looks like below:-
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- Daily rollover -->
<fileNamePattern>/tmp/SolrUpdater.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- Keep 7 days' worth of history -->
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</configuration>
Maven dependencies looks like below:-
<?xml version="1.0" encoding="UTF-8"?>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.13</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.13</version>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.0.13</version>
</dependency>
</dependencies>
I have also verified that src/main/resource
is marked as resource directory in eclipse as shown below:-
Can someone let me know what is going wrong?
Upvotes: 1
Views: 1609
Reputation: 12885
You cannot use two logging backends at the same time. You should be seeing a runtime warning about multiple SLF4J implementations on the classpath.
slf4j-jdk14
precedes logback-classic
in your dependency list, so all log messages get routed to the java.util.logging
backend, and your Logback configuration has no effect at all.
Remove the slf4j-jdk14
dependency and make sure you don't have any other SLF4J backends as transitive dependencies.
Upvotes: 1
Reputation: 2978
Probably src/main/resources has not been recognized as a resource directory by eclipse and need some refresh or action to do that.
Do you check that this directory is marked as resource directory in project configuration ?
Upvotes: 0