- Spring 5.0 Projects
- Nilang Patel
- 118字
- 2021-07-02 12:34:59
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>
推薦閱讀
- 面向物聯(lián)網(wǎng)的CC2530與傳感器應(yīng)用開發(fā)
- 城域網(wǎng)與廣域網(wǎng)(第2版)
- 物聯(lián)網(wǎng)與智能家居
- React Cookbook
- 人人都該都懂的互聯(lián)網(wǎng)思維
- Getting Started with nopCommerce
- Hands-On Microservices with Node.js
- 局域網(wǎng)組成實踐
- Hands-On Bitcoin Programming with Python
- Web用戶查詢?nèi)罩就诰蚺c應(yīng)用
- 人際網(wǎng)絡(luò)
- 現(xiàn)場綜合化網(wǎng)絡(luò)運營與維護:運營商數(shù)字化轉(zhuǎn)型技術(shù)與實踐
- 小型局域網(wǎng)組建
- Migrating to Drupal7
- ElasticSearch Server