Search code examples
loggingslf4jjava.util.logging

Different logging level between SFL4J and JDK logging


I am using JDK logging as a logging framework and SLF4J as simple facade. I have some queries when I log different level logs.

SLF4J has following log levels

trace (the least serious)<br>
debug<br>
info<br>
warn<br>
error<br>
fatal (the most serious)<br>

JDK logging has following log levels

SEVERE (highest value)<br>
WARNING<br>
INFO<br>
CONFIG<br>
FINE<br>
FINER<br>
FINEST (lowest value)<br>

If I want to set the log level to DEBUG then that level is not available in JDK logging. Can anybody please explain how can we get the DEBUG level logging in this situation. Do we need to do any additional configuration for this situation?

Updated

this is my property file configuration

handlers = com.amc.logging.handlers.DebugLogHandler

com.amc.logging.handlers.DebugLogHandler.pattern=c:/logs/debug_log.log
com.amc.logging.handlers.DebugLogHandler.level=FINE
com.amc.logging.handlers.DebugLogHandler.formatter=java.util.logging.SimpleFormatter
com.amc.logging.handlers.DebugLogHandler.append=true

Please let me know where I went wrong.


Solution

  • I have solved this issue with the help of bellow post.

    slf4j logging with jdk – how to enable debug?

    For DEBUG level logging in SLF4J we have to map FINE level in java.util.logging.

    And we have to set the default logging level as FINE or lower level of FINE. This can be achieved by putting the bellow line in logging configuration file.

    .level= FINE