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

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>
主站蜘蛛池模板: 香格里拉县| 电白县| 中牟县| 邵东县| 田林县| 钟山县| 伊春市| 博乐市| 富源县| 双辽市| 泸水县| 黄浦区| 乌兰浩特市| 特克斯县| 博白县| 军事| 营山县| 库伦旗| 民丰县| 沈阳市| 德清县| 安仁县| 循化| 苏尼特右旗| 周口市| 苍梧县| 和硕县| 荃湾区| 台南市| 酒泉市| 怀来县| 四子王旗| 娄底市| 乌兰浩特市| 浦东新区| 五寨县| 环江| 甘肃省| 施秉县| 古丈县| 二连浩特市|