Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Logback Config – Showing Debug Level

DZone's Guide to

Logback Config – Showing Debug Level

· Java Zone ·
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

Showing Debug Logback Configuration

Logback provides the functionality to enable debug level output of its own status.

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">

yields 

INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [file:/code/MyProject/target/test-classes/logback-test.xml]
INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [console]
INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.myco] to DEBUG
INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.test.web.servlet] to TRACE
INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.web.servlet] to TRACE
INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to WARN
INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [console] to Logger[ROOT]
INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
INFO in ch.qos.logback.classic.joran.JoranConfigurator@2c17306 - Registering current configuration as safe fallback point

However, I started using the logback.groovy configuration and I cannot seem to find a way to enable debug in the groovy config. We can turn on debug info via an environment variable logback.debug

  • Environment Variable: logback.debug=true
  • Java Define: -Dlogback.debug=true

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}