当前位置:网站首页>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 ");
}
}
边栏推荐
- Embedded System Development Notes 80: using QT designer to design the main interface
- Common thread methods and daemon threads
- TS type gymnastics: illustrating a complex advanced type
- 做网站数据采集,怎么选择合适的服务器呢?
- (12) Somersault cloud case (navigation bar highlights follow)
- It's settled! 2022 JD cloud summit of JD global technology Explorer conference see you in Beijing on July 13
- TASK04|数理统计
- 嵌入式系統開發筆記80:應用Qt Designer進行主界面設計
- Loop filtering based on Unet
- 跳槽一次涨8k,5年跳了3次...
猜你喜欢

【人话版】WEB3黑暗森林中的隐私博弈

283. move zero

JMeter learning notes 2 - brief introduction to graphical interface

Mallbook: how can hotel enterprises break the situation in the post epidemic era?

2022危险化学品生产单位安全生产管理人员题库及答案

Web components series (VIII) -- custom component style settings

使用WinMTR软件简单分析跟踪检测网络路由情况

TS type gymnastics: illustrating a complex advanced type

类和对象收尾

In the innovation community, the "100 cities Tour" of the gold warehouse of the National People's Congress of 2022 was launched
随机推荐
离线安装wireshark2.6.10
NFT: start NFT royalty journey with eip-2981
TS type gymnastics: illustrating a complex advanced type
Qt development experience tips 226-230
【人话版】WEB3黑暗森林中的隐私博弈
What are permissions? What are roles? What are users?
Knowledge supplement: redis' basic data types and corresponding commands
2. Use of classlist (element class name)
Threejs opening
Haskell lightweight threads overhead and use on multicores
【发送邮件报错】535 Error:authentication failed
2022年G1工业锅炉司炉特种作业证考试题库及在线模拟考试
Coinbase in a bear market: losses, layoffs, stock price plunges
基于Unet的环路滤波
LeetCode 1399. Count the maximum number of groups
总结全了,低代码还需要解决这4点问题
Dual Contrastive Learning: Text Classification via Label-Aware Data Augmentation 阅读笔记
跳槽一次涨8k,5年跳了3次...
MySQL advanced -- you will have a new understanding of MySQL
NFT:使用 EIP-2981 开启 NFT 版税之旅