Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 872
Java-Seekar Avatar asked Apr 04 '13 10:04

Java-Seekar


People also ask

What is the default logging level in SLF4J?

Spring Boot makes use of Apache Commons' Logging for its system logs by default. Additionally, by default you can use any of the logging frameworks under the SLF4J API such as Logback (which is the default), Log4J2, and Java Util Logging in Spring Boot.

What are the five levels of logging?

The possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is INFO.


1 Answers

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

like image 199
Java-Seekar Avatar answered Sep 18 '22 16:09

Java-Seekar