We help IT Professionals succeed at work.
Get Started

Understanding logback.xml file

Rohit Bajaj
Rohit Bajaj asked
on
714 Views
Last Modified: 2016-05-01
HI,
I am using the following file in my java maven project :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>
                %d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
            </pattern>
        </encoder>    </appender>
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>yatra.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- daily rollover -->
            <fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>

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

        </rollingPolicy>

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

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

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

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 ?

Thanks
Comment
Watch Question
Sr. Consultant
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE