Java loggers levels

Here is a quick summary about Logback (and logging).
In your project, you’ll use slf4j, which is a facade, behind which you’ll plug a logging implementation.

Apache Jakarta Commons Logging (JCL) has memory leaks, so don’t use it.
Log4J has been deprecated by Logback, so don’t use it in new projects.
Logback is the logging API you should use.

The info which you (especially I) should learn by heart is the list of the different logging levels:

The set of possible levels, from highest to lowest:


if you put the level to INFO, everything from INFO down to ERROR will be displayed
if you put the level to DEBUG, everything from DEBUG down to ERROR will be displayed

When setting the logback.xml config file, just set the root logger on the warn level, or you’ll get tons of logs lines, too many.
Instead, override the root level only for your packages, say you have your code under package : com.mycompany

you use something like

  <logger name="com.mycompany" level="debug"/>

Here is a simple logback.xml config to get you started


<appender name="STDOUT">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>

<logger name="com.mycompany" level="debug"/>
<logger name="org.something.else" level="info"/>

<root level="warn">
<appender-ref ref="STDOUT" />


One thought on “Java loggers levels

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s