Detailed Configuration logback.xml (rpm)

<? XML Version = "1.0" encoding = "UTF-. 8"> 

<Configuration> 

    <-! disposed console log output format -> 
    <the appender name = "consolelog" class = "ch.qos.logback.core. the ConsoleAppender "> 
        <layout class =" ch.qos.logback.classic.PatternLayout "> 
            <pattern> 
                % D -% MSG% n-
             </ pattern> 
        </ layout> 
    </ the appender> 

    <-! ERROR set of records in the log file ->     
    <appender name = "fileInfoLog" class = "ch.qos.logback.core.rolling.RollingFileAppender"> 
        <- filter:! matched filtering, log on to perform matching strategy to match ->
        <filter class="ch.qos.logback.classic.filter.LevelFilter"> 
            <-! matching level ->
            <Level> ERROR </ Level> 
            <-! matched to the implementation of the policy -> 
            <onMatch> DENY </ onMatch> 
            <-! mismatch implementation strategy -> 
            <onMismatch> ACCEPT </ onMismatch> 
        </ filter> 
        <Encoder> 
            <pattern> 
                % msg% the n-
             </ pattern> 
        </ Encoder> 
        <-! scroll policy -> 
        <rollingPolicy class = "ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
            <! - - path -> 
            <fileNamePattern> /var/log/tomcat/sell/info.%d.log </ fileNamePattern> 
        </ rollingPolicy> 
    </ the appender>

    <! - set the record ERROR log file ->
            <! - Path ->
    <the appender name = "fileErrorLog" class = "ch.qos.logback.core.rolling.RollingFileAppender"> 
        <- Filter:! threshold filtering, only the log records ERROR level above -> 
        <filter class = "CH. qos.logback.classic.filter.ThresholdFilter "> 
            <Level> ERROR </ Level> 
        </ filter> 
        <Encoder> 
            <pattern> 
                % msg% the n-
             </ pattern> 
        </ Encoder> 
        <-! scroll policy -> 
        <rollingPolicy class = "ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
            <fileNamePattern>/var/log/tomcat/sell/error.%d.log</fileNamePattern>
        </rollingPolicy>
    </appender>

    <root>
        <appender-ref ref="consoleLog">
        <appender-ref ref="fileInfoLog">
        <appender-ref ref="fileErrorLog">
    </root>

</configuration>

Root <Configuration>
Scan: When this property is set to true, if the profile change, will be reloaded. The default value is true.
scanPeriod: Set if there are modified profiles monitoring interval, if the time unit is not given, the default milliseconds. When the scan is true, this property take effect. The default interval is 1 minute.
debug: When this property is set to true, will print logback internal log information, real-time view logback running. The default value is false.
<contextName>: Each logger logger is associated to the context, the default context name is "default". However, other names may be used provided, for distinguishing between different recording applications. Once set, can not be modified, may be referenced by the name of the context log contextName can%
<Property>: variable value is used to define the tag, will be inserted into logger value defined by the context. After the definition of variables, can be used in variable $ {}.
<appender>: to format the log output nodes,
there are two attributes name and class, class for policy specifies which output, is commonly used:
the console output policy (class = ch.qos.logback.core.ConsoleAppender)
< layout>
class = ch.qos.logback.classic.PatternLayout: console log output mode
<pattern>: set the logging line format
file output policy (class = ch.qos.logback.core.rolling.RollingFileAppender)
Common log output to a file, with the application of more and more time running, the log will grow more and more, they will be output to the same file is not a good idea, ch.qos.logback.core.rolling. RollingFileAppender for slicing a log file
<filter>
class = ch.qos.logback.classic.filter.LevelFilter: matched filtering, policy matching to perform matching log
<level>: matching level
execution policy matching to: <onMatch>
<onMisMatch>: execution policy does not match the
class = ch.qos.logback.classic.filter.ThresholdFilter: filtering threshold, only the logging level than
<level>: matching level
<Encoder>
<pattern>: set logging row format
<rollingPolicy>
class = ch.qos.logback.core.rolling.TimeBasedRollingPolicy: log file according to time division, generating a day, which may daily log file size is not fixed
class = ch.qos.logback.core.rolling. SizeBasedTriggeringPolicy: The file size is divided, each maxFileSize to achieve a segmented file
class = ch.qos.logback.core.rolling.SizeAndTimeBasedRolling Policy: According to the same time every day and split the log file size,
<fileNamePattern>: definition of the partition name rule log file
<maxHistory>: indicates keep only the last N days of log to prevent the log from filling the entire disc space
<totalSizeCap>: Specifies the maximum size of the log file, set, for example, then a 1GB, so to this value, it will delete the old log
<root>: used to specify the most basic level log output, may contain zero or more <appender-ref>, identifies the appender will be added to the logger.
level: the level used to set the print, case insensitive: TRACE, DEBUG, INFO, WARN , ERROR, ALL and OFF
<REF-the appender>
REF: point <appender> name attribute
<logger>: used to set one or packet the level of a particular print log of a class, and to specify the appender
name: a packet logger used to specify a particular constraint or affected by a certain class.
level: used to set the printing level, case-insensitive: TRACE, DEBUG, INFO, WARN , ERROR, ALL and OFF, if this property is not set, then the current logger will inherit the higher level of the so-called transfer to their superiors is whether to use the root configuration
addtivity: whether to transmit print information to their superiors logger. Defaults to true
<REF-the appender>
REF: point <appender> name attribute
logback asynchronous output log
General logging configuration, each time the log output file will be synchronized to a disk IO is based. Using asynchronous write log and not let this happen to write the log disk IO, blocking the thread causing unnecessary performance loss. Asynchronous output log is simple, add an appender to write asynchronous log-based and point appender to the original configuration.

<! - asynchronous output -> 
<the appender name = "ASYNC-the INFO" class = "ch.qos.logback.classic.AsyncAppender"> 
    <! - the log is not lost, the default, if the queue is full 80% , is discarded TRACT, DEBUG, INFO level log -> 
    <discardingThreshold> 0 </ discardingThreshold> 
    <-! change the default depth of the queue, this value can affect performance, the default value is 256 -> 
    <QueueSize> 256 </ QueueSize> 
    <-! add additional appender, only add up to a -> 
    <appender-ref ref = "INFO-LOG" /> 
</ appender>

 


----------------
Disclaimer: This article is CSDN blogger "a615883576" of the original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/A615883576/article/details/81226255

Guess you like

Origin www.cnblogs.com/muxi0407/p/11812799.html