当前位置:网站首页>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>
边栏推荐
- Use moviepy Editor clips videos and intercepts video clips in batches
- 融云斩获 2022 中国信创数字化办公门户卓越产品奖!
- Three singleton modes of unity (hungry man, lazy man, monobehavior)
- 121. The best time to buy and sell stocks
- PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
- leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
- Regular expression string
- IP地址和物理地址有什么区别
- Laravel5.1 路由 -路由分组
- [summary of knowledge] summary of notes on using SVN in PHP
猜你喜欢
Apache Doris just "graduated": why should we pay attention to this kind of SQL data warehouse?
企业级日志分析系统ELK
深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3
Rongyun won the 2022 China Xinchuang digital office portal excellence product award!
Dotween -- ease function
How does geojson data merge the boundaries of regions?
Leetcode-231-2的幂
Unity3d click events added to 3D objects in the scene
平衡二叉树(AVL)
随机推荐
分步式监控平台zabbix
用手机在通达信上开户靠谱吗?这样炒股有没有什么安全隐患
分类模型评价标准(performance measure)
安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是
Eye of depth (VI) -- inverse of matrix (attachment: some ideas of logistic model)
Mysql database backup script
【C 语言】 题集 of Ⅹ
Particle effect for ugui
What about the pointer in neural network C language
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
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
Laravel 服务提供者实例教程 —— 创建 Service Provider 测试实例
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3
【Vulnhub靶场】THALES:1
Dotween -- ease function
HAVE FUN | “飞船计划”活动最新进展
Rongyun won the 2022 China Xinchuang digital office portal excellence product award!
php 自带过滤和转义函数
Communication mode between application program and MATLAB
Detailed explanation of several ideas for implementing timed tasks in PHP