Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logback not logging to console at all

I cannot log to the console using logback. Nothing is showing up when I run my application.

here my logback file content

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

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
        <Pattern>
            %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} -
            %msg%n
        </Pattern>
    </layout>
</appender>



<root level="error">
    <appender-ref ref="STDOUT" />
</root>
<root level="DEBUG">
    <appender-ref ref="STDOUT" />
</root>

for example I can't get the message "Starting debugging":

logger.debug("Starting debugging");

        ConnectorTopology ConnectorTopology= new ConnectorTopology();

and my topology of storm is working 100%

like image 528
h.zak Avatar asked Oct 24 '25 07:10

h.zak


1 Answers

You should never use multiple root-elements. Remove one of them and set the level of the remaining one to DEBUG.

Also the pattern-tag should be enclosed in an encoder-tag, not a layout-tag:

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  <encoder>
    <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
  </encoder>
</appender>

See the manual for more details: http://logback.qos.ch/manual/appenders.html#ConsoleAppender

like image 159
sheltem Avatar answered Oct 26 '25 23:10

sheltem