- 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>
推薦閱讀
- 計算機網絡與通信(第2版)
- 黑客攻防實戰技術完全手冊:掃描、嗅探、入侵與防御
- RCNP實驗指南:構建高級的路由互聯網絡(BARI)
- Modern JavaScript Web Development Cookbook
- Building Django 2.0 Web Applications
- Django 2 by Example
- Learning QGIS 2.0
- 通信簡史:從信鴿到6G+
- 企業私有云建設指南
- Socket.IO Real-time Web Application Development
- 中小型局域網組建、管理與維護實戰
- 計算機網絡工程實用教程(第2版)
- 區塊鏈輕松上手:原理、源碼、搭建與應用
- 5G技術與標準
- 6G:面向2030年的移動通信