当前位置:网站首页>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>
边栏推荐
- 【Vulnhub靶场】THALES:1
- 【HCSD大咖直播】亲授大厂面试秘诀-简要笔记
- SysOM 案例解析:消失的内存都去哪了 !| 龙蜥技术
- asyncio 概念和用法
- hellogolang
- hellogolang
- PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
- Laravel service provider instance tutorial - create a service provider test instance
- What are compiled languages and interpreted languages?
- Set the route and optimize the URL in thinkphp3.2.3
猜你喜欢
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3
Three. JS introductory learning notes 19: how to import FBX static model
Logback日志框架第三方jar包 免费获取
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"?
What are compiled languages and interpreted languages?
企业级日志分析系统ELK
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
Strengthen real-time data management, and the British software helps the security construction of the medical insurance platform
Unity3D_ Class fishing project, bullet rebound effect is achieved
95. (cesium chapter) cesium dynamic monomer-3d building (building)
随机推荐
Xcode Revoke certificate
喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
TiDB For PostgreSQL和YugabyteDB在Sysbench上的性能对比
thinkphp3.2.3中设置路由,优化url
How to implement backspace in shell
[excelexport], Excel to Lua, JSON, XML development tool
php 自带过滤和转义函数
模仿企业微信会议室选择
Sysom case analysis: where is the missing memory| Dragon lizard Technology
Iptables only allows the specified IP address to access the specified port
Migration and reprint
深度之眼(六)——矩阵的逆(附:logistic模型一些想法)
Numpy --- basic learning notes
Performance comparison of tidb for PostgreSQL and yugabytedb on sysbench
Leetcode-231-2的幂
markdown公式编辑教程
Dotween -- ease function
安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是
Application example of infinite list [uigridview]
IP地址和物理地址有什么区别