当前位置:网站首页>Simple implementation of slf4j
Simple implementation of slf4j
2022-07-01 04:24:00 【Little Taoist writes program】
First of all : Profile location , name ;

second : The configuration file Content :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Define the storage address of the log file Stay away LogBack The relative path is used in the configuration of -->
<property name="LOG_HOME" value="d:/log" />
<!-- Console output -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- Log output code -->
<!-- <Encoding>UTF-8</Encoding>-->
<layout class="ch.qos.logback.classic.PatternLayout">
<!-- Format output :%d Indicates the date ,%thread Represents the thread name ,%-5level: The level is shown from the left 5 Character width %msg: Log message ,%n Is a newline -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SS} [%thread] %-5level %logger{50} - %msg%n
</pattern>
</layout>
</appender>
<!-- Generate log files per day -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <Encoding>UTF-8</Encoding>-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- The filename of the log file output -->
<FileNamePattern>${LOG_HOME}/myApp.log.%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<!-- Format output :%d Indicates the date ,%thread Represents the thread name ,%-5level: The level is shown from the left 5 Character width %msg: Log message ,%n Is a newline -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
</pattern>
</layout>
<!-- Maximum log file size -->
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>10MB</MaxFileSize>
</triggeringPolicy>
</appender>
<!-- Log output level -->
<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
<!-- Log asynchronously to database -->
<!--<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">-->
<!-- Log asynchronously to database -->
<!-- <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource"> -->
<!-- Connection pool -->
<!-- <dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">
<driverClass>com.mysql.jdbc.Driver</driverClass>
<url>jdbc:mysql://127.0.0.1:3306/databaseName</url>
<user>root</user>
<password>root</password>
</dataSource>
</connectionSource>
</appender>-->
</configuration>
application.yml
server:
port: 8082
logging:
config:
classPath: logback.xml
Third : application
package com.logtest.demo.action;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class LogAction {
private static final Logger logger = LoggerFactory.getLogger(LogAction.class);
@GetMapping("/hello")
public void hello(){
// logger.trace("trace");
logger.debug("debug");
logger.info("info");
logger.warn("warn");
logger.error("error");
logger.error(" I am mistaken ");
}
}
边栏推荐
- Internet winter, how to spend three months to make a comeback
- 多次跳槽后,月薪等于老同事的年薪
- Day 52 - tree problem
- LeetCode 1400. Construct K palindrome strings
- [leetcode skimming] February summary (updating)
- NFT: utilisez EIP - 2981 pour commencer un voyage de redevances NFT
- MySQL advanced -- you will have a new understanding of MySQL
- 674. longest continuous increasing sequence force buckle JS
- Jenkins自动清理构建历史
- Codeforces Round #721 (Div. 2)B1. Palindrome Game (easy version)B2. Palindrome game (hard version)
猜你喜欢

Do280 management application deployment --rc

2022年聚合工艺考试题及模拟考试

NFT:使用 EIP-2981 开启 NFT 版税之旅

采购数智化爆发在即,支出宝'3+2'体系助力企业打造核心竞争优势

25.K个一组翻转链表
![[human version] Web3 privacy game in the dark forest](/img/89/e16789b7f3892002748aab309c45e6.png)
[human version] Web3 privacy game in the dark forest

slf4j 简单实现

LeetCode 1828. Count the number of points in a circle

软件研发的十大浪费:研发效能的另一面

In the innovation community, the "100 cities Tour" of the gold warehouse of the National People's Congress of 2022 was launched
随机推荐
2022年聚合工艺考试题及模拟考试
MySQL function variable stored procedure
Embedded System Development Notes 80: using QT designer to design the main interface
JMeter学习笔记2-图形界面简单介绍
Jenkins automatically cleans up construction history
Qt development experience tips 226-230
为什么香港服务器最适合海外建站使用
(12) Somersault cloud case (navigation bar highlights follow)
Analyse et cas du modèle pageobject
【LeetCode】100. Same tree
“目标检测“+“视觉理解“实现对输入图像的理解
离线安装wireshark2.6.10
[human version] Web3 privacy game in the dark forest
Odeint and GPU
"Target detection" + "visual understanding" realizes the understanding of the input image
Threejs opening
不同性能测试工具的并发模式
LeetCode 1400. Construct K palindrome strings
Note de développement du système embarqué 80: application du concepteur Qt à la conception de l'interface principale
2022年T电梯修理题库及模拟考试