I created a simple web application with slf4j-logback
logging. I used the below configuration that prints log statements to mylog.log
file.
<configuration>
<appender name="fileAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${catalina.base}/logs/mylog.log</File>
<encoder>
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{35} - %msg %n
</Pattern>
</encoder>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="fileAppender" />
</root>
</configuration>
The above worked fine.
I came across one logger
element as
<logger name="mylog" additivity="false">
<level value="DEBUG" />
<appender-ref ref="fileAppender" />
</logger>
What is the use of this logger
element? Will it make any difference as my first configuration worked fine?
The <logger>
is not needed because you are using <root>
logger. The root
configuration is inherited by children logger
configurations and can be overriden. See Logback configuration documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With