当前位置:网站首页>logback. XML configure logs of different levels and set color output
logback. XML configure logs of different levels and set color output
2022-07-07 16:24:00 【kill-java】
yml perhaps properties The configuration file
logging.config=classpath:logback.xml
resources New under the directory logback.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!-- Root tag -->
<configuration>
<!-- Set a variable ,name Variable name ,value Value , have access to ${
Variable name } Way to use -->
<property name="DIR" value="log"/>
<property name="LOG_HOME" value="/F:/project/logs"/>
<property name="NAME" value="log"/>
<property name="MDC_LOG_PATTERN"
value="%red(%d{yyyy-MM-dd'T'HH:mm:ss.SSS}) %green(%p filesystem %t) %blue(%logger{50}) %yellow([line:%L %msg]%n)"></property>
<!-- Run loggers , Date roll record -->
<appender name="info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- The path and filename of the log file being logged -->
<file>${
LOG_HOME}/${
NAME}/info/${
NAME}.log</file>
<!-- Rolling policy for loggers , By date , Record by size -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${
LOG_HOME}/${
NAME}/info/${
NAME}-%d{
yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- In addition to logging , It is also configured that the log file cannot exceed 50M, If more than 50M, Log files will be indexed 0 Start , Name the log file , for example bizlog-biz-20181219.0.log -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
<!-- Storage time 3 God -->
<!--<MaxHistory>3</MaxHistory>-->
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- Add method to record log -->
<append>true</append>
<!-- Format of log file -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{
yyyy/MM/dd' 'HH:mm:ss.SSS} %X{
req.requestId}[line:%L %msg] %n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- This log file only records info Grade -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- The path and filename of the log file being logged -->
<file>${
LOG_HOME}/${
NAME}/error/${
NAME}.log</file>
<!-- Rolling policy for loggers , By date , Record by size -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${
LOG_HOME}/${
NAME}/error/${
NAME}-%d{
yyyy-MM-dd}.%i.log</fileNamePattern>
<!-- In addition to logging , It is also configured that the log file cannot exceed 50M, If more than 50M, Log files will be indexed 0 Start , Name the log file , for example bizlog-biz-20181219.0.log -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>50MB</maxFileSize>
<!-- Storage time 3 God -->
<!--<MaxHistory>3</MaxHistory>-->
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<!-- Add method to record log -->
<append>true</append>
<!-- Format of log file -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{
yyyy/MM/dd' 'HH:mm:ss.SSS} %X{
req.requestId}[line:%L %msg] %n</pattern>
<charset>utf-8</charset>
</encoder>
<!-- This log file only records info Grade -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>error</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!--ConsoleAppender Is printed to the console -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!--encoder Default configuration is PatternLayoutEncoder-->
<encoder>
<pattern>${
MDC_LOG_PATTERN}</pattern>
<charset>utf-8</charset>
</encoder>
<!-- This log appender It's for development , Configure only the lowest level , The console output log level is greater than or equal to this level of log information -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>all</level>
</filter>
</appender>
<!-- root loger. only one level attribute , It should have been named "root".-->
<root level="info">
<appender-ref ref="info"/>
<appender-ref ref="STDOUT"/>
<appender-ref ref="error"/>
</root>
</configuration>
边栏推荐
- Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"
- Communication mode between application program and MATLAB
- TCP framework___ Unity
- Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
- 121. 买卖股票的最佳时机
- prometheus api删除某个指定job的所有数据
- Unity3d click events added to 3D objects in the scene
- 【Vulnhub靶场】THALES:1
- Three singleton modes of unity (hungry man, lazy man, monobehavior)
- Mysql database basic operation DQL basic query
猜你喜欢
Numpy -- epidemic data analysis case
spark调优(三):持久化减少二次查询
Eye of depth (VI) -- inverse of matrix (attachment: some ideas of logistic model)
【C 语言】 题集 of Ⅹ
What about the pointer in neural network C language
Step by step monitoring platform ZABBIX
Excessive dependence on subsidies, difficult collection of key customers, and how strong is the potential to reach the dream of "the first share of domestic databases"?
You Yuxi, coming!
融云斩获 2022 中国信创数字化办公门户卓越产品奖!
Application example of infinite list [uigridview]
随机推荐
Description of vs common shortcut keys
分类模型评价标准(performance measure)
Step by step monitoring platform ZABBIX
What else can an ordinary person do besides working in a factory to make money?
IP地址和物理地址有什么区别
Shipping companies' AI products are mature, standardized and applied on a large scale. CIMC, the global leader in port and shipping AI / container AI, has built a benchmark for international shipping
Leetcode-136- number that appears only once (solve with XOR)
The differences between exit, exit (0), exit (1), exit ('0 '), exit ('1'), die and return in PHP
统计学习方法——感知机
U3D_ Infinite Bessel curve
删除 console 语句引发的惨案
【Vulnhub靶场】THALES:1
Laravel service provider instance tutorial - create a service provider test instance
Numpy -- data cleaning
HAVE FUN | “飞船计划”活动最新进展
SPI master RX time out interrupt
Notification uses full resolution
PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
Shader basic UV operations, translation, rotation, scaling
[vulnhub range] thales:1