Avatar of Rohit Bajaj
Rohit Bajaj
Flag for India

asked on 

Understanding logback.xml file

I am using the following file in my java maven project :
<?xml version="1.0" encoding="UTF-8"?>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
                %d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
        </encoder>    </appender>
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- daily rollover -->

            <!-- keep 30 days' worth of history capped at 3GB total size -->


            <pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n

    <logger name="chatAdapter" level="debug" additivity="false">
        <appender-ref ref="STDOUT" />
    <logger name="SMRunner" level="debug" additivity="false">
        <appender-ref ref="STDOUT" />
    <logger name="stateMachine" level="debug" additivity="false">
        <appender-ref ref="STDOUT" />

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

Open in new window

This file resides in my top directory and inside it i have different modules like chatAdapter, stateMachine etc.

I have two questions :
1) Whats the meaning of defining root tag here ? Is it doing anything
2) As all of chatAdapter, stateMachine etc.. have the same logging conditions... Can i somehow avoid writing all of them and specify a common one for all the modules and yet have only one logback.xml file in the  project ?


Avatar of undefined
Last Comment
Am P

8/22/2022 - Mon