当前位置:网站首页>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 ");
}
}
边栏推荐
- One job hopping up 8K, three times in five years
- 25.K个一组翻转链表
- 【发送邮件报错】535 Error:authentication failed
- [recommended algorithm] C interview question of a small factory
- Possible problems and solutions of using scroll view to implement slider view
- 浏览器顶部loading(来自知乎)
- selenium打开chrome浏览器时弹出设置页面:Mircrosoft Defender 防病毒要重置您的设置
- Recommend the best product development process in the Internet industry!
- 做网站数据采集,怎么选择合适的服务器呢?
- Obtain detailed ideas for ABCDEF questions of 2022 American Games
猜你喜欢
![[deep learning] (4) decoder mechanism in transformer, complete pytoch code attached](/img/ec/96e3188902e399f536ebca79042af9.png)
[deep learning] (4) decoder mechanism in transformer, complete pytoch code attached

OdeInt與GPU

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

"Target detection" + "visual understanding" realizes the understanding of the input image

Introduction of Spock unit test framework and its practice in meituan optimization___ Chapter I
![[recommended algorithm] C interview question of a small factory](/img/ae/9c83efe86c03763710ba5e4a2eea33.jpg)
[recommended algorithm] C interview question of a small factory

Unity之三维空间多点箭头导航

使用scroll-view实现滑块视图可能遇到的问题及其解决方法

MallBook:后疫情时代下,酒店企业如何破局?

JMeter learning notes 2 - brief introduction to graphical interface
随机推荐
嵌入式系统开发笔记79:为什么要获取本机网卡IP地址
细数软件研发效能的七宗罪
Procurement intelligence is about to break out, and Alipay'3+2'system helps enterprises build core competitive advantages
2022年T电梯修理题库及模拟考试
Codeforces Round #721 (Div. 2)B1. Palindrome Game (easy version)B2. Palindrome game (hard version)
分账技术赋能农贸市场,重塑交易管理服务效能
Valid @suppresswarnings warning name
JS rotation chart
Account sharing technology enables the farmers' market and reshapes the efficiency of transaction management services
OdeInt與GPU
Use winmtr software to simply analyze, track and detect network routing
Recommend the best product development process in the Internet industry!
[deep learning] (4) decoder mechanism in transformer, complete pytoch code attached
Qt开发经验小技巧226-230
互联网行业最佳产品开发流程 推荐!
高并发下接口幂等性如何保证?
Coinbase in a bear market: losses, layoffs, stock price plunges
OSPF notes [dr and bdr]
Threejs opening
283. move zero