Have a problem with logback. I've tried to log my actions, want to write all logs to file, but there are no logs at all after start of my application
logback.xml
<configuration>
<appender name="FILE-LOGGER" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/application.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<fileNamePattern>log/application-%d{yyyy-MM-dd}.log%i</fileNamePattern>
<maxFileSize>5MB</maxFileSize>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="com.test.application" level="info">
<appender-ref ref="FILE-LOGGER"/>
</logger>
<root level="debug">
<appender-ref ref="FILE-LOGGER"/>
</root>
</configuration>
service.java
static final Logger LOG = LoggerFactory.getLogger(TestClass.class);
public List<Items> getAll(){
LOG.info("hi, info!!!!!");
LOG.error("hi, error!!!!!");
}
pom.xml
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j-version}</version>
</dependency>
expect that logs will be in the log file
Accidentaly I found an issue I delete file from logback.xml and started to receive logs in console and found next interesting rows:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:org/slf4j/slf4j-simple/1.7.26/slf4j-simple-1.7.26.jar!/org/slf4j/impl/StaticLoggerBinder.class]
ERROR in ch.qos.logback.core.joran.util.PropertySetter@100454a1 - A "ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy" object is not assignable to a "ch.qos.logback.core.rolling.RollingPolicy" variable.
To fix this issue you need to do next steps: