官术网_书友最值得收藏!

Logging configuration

Before we jump into the rest of the steps to develop an application, it is good practice to define a log level and format. It is, however, optional but good practice to print the logs in a desired format, along with various logging levels. For this, add an XML file called logback.xml with following content in it:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<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>
<logger name="com.nilangpatel.worldgdp" level="debug" additivity="false">
<appender-ref ref="STDOUT" />
</logger>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>

Logback was developed as a successor to the popular Log4j project, and is used as a logging framework for Java applications. This configuration defines the pattern, along with the logging level. To enable logback in your application, you need to add following dependencies to pom.xml:

  <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
主站蜘蛛池模板: 连州市| 霍林郭勒市| 桐梓县| 乐都县| 益阳市| 米林县| 和林格尔县| 自贡市| 永兴县| 墨竹工卡县| 扎兰屯市| 东阿县| 博罗县| 昭平县| 会同县| 贵溪市| 阳春市| 乐至县| 东莞市| 安庆市| 莲花县| 卢龙县| 大名县| 探索| 黄山市| 兰西县| 从化市| 伊吾县| 报价| 报价| 会理县| 绵竹市| 闽侯县| 南涧| 齐河县| 饶阳县| 龙海市| 师宗县| 磐石市| 通海县| 工布江达县|