I am using below code to change log level at runtime in logback.
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
However I am getting ClassCastException with message:
org.slf4j.helpers.NOPLogger cannot be cast to ch.qos.logback.classic.Logger
My pom has these dependencies:
<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>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
I am not able to figure out whats wrong here. I can see many examples using this code. But its not working for me. I want to change log level dynamically so I am using Logger class from classic instead of slf4j. Can anybody help me identifying where I am wrong?