zoukankan      html  css  js  c++  java
  • logback配置

    小Demo 

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration scan="false" scanPeriod="60 seconds" debug="false">
    <contextName>wsbs</contextName>
    <!-- 定义日志出输出路径 -->
    <property name="LOG_PATH" value="./data/logs/wsbs" />
    <property name="LOG_PATTERN"
    value=".%d{yyyy/MM/dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg %n" />
    <!-- <property name="LOG_PATTERN" value= ".%d{HH:mm:ss.SSS} [%thread] %-5level
    %logger{36} - %msg %n" /> -->

    <!-- 控制台输出 -->
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
    <Pattern>
    ${LOG_PATTERN}
    </Pattern>
    </encoder>
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
    <level>TRACE</level>
    </filter>
    </appender>

    <!-- 按天滚动文件输出 -->
    <appender name="FILE"
    class="ch.qos.logback.core.rolling.RollingFileAppender">
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
    <level>INFO</level>
    </filter>
    <File>${LOG_PATH}/all_log.txt</File>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <!-- daily rollover -->
    <FileNamePattern>
    ${LOG_PATH}/all_log.%d{yyyy-MM-dd}.%i.txt
    </FileNamePattern>
    <timeBasedFileNamingAndTriggeringPolicy
    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
    <maxFileSize>300MB</maxFileSize>
    </timeBasedFileNamingAndTriggeringPolicy>
    <!-- keep 30 days' worth of history -->
    <maxHistory>30</maxHistory>
    </rollingPolicy>
    <!-- append是否接着上次写文件结尾继续写,默认为true -->
    <append>true</append>
    <encoder>
    <Pattern>
    ${LOG_PATTERN}
    </Pattern>
    </encoder>
    </appender>

    <!-- spring日志输出 -->
    <logger name="org.springframework" level="WARN" />
    <logger name="com.netflix" level="WARN" />
    <logger name="org.apache.http" level="WARN" />
    <logger name="org.apache.coyote" level="WARN" />
    <logger name="ch.qos.logback" level="WARN" />
    <logger name="druid.sql" level="WARN" />
    <logger name="com.alibaba.druid" level="WARN" />

    <!-- hibernate日志输出 -->
    <logger name="org.hibernate" level="WARN" />
    <logger name="org.hibernate.type.descriptor.sql.BasicBinder"
    level="DEBUG" />
    <logger name="org.hibernate.type.descriptor.sql.BasicExtractor"
    level="DEBUG" />
    <logger name="org.hibernate.SQL" level="DEBUG" />
    <logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
    <logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />

    <!-- 配置sql中日志输出级别 -->
    <logger name="java.sql" level="DEBUG" />

    <!-- 配置ibatis中日志输出级别 -->
    <logger name="org.mybatis" level="WARN" />
    <logger name="org.apache.ibatis" level="WARN" />
    <!-- 配置ibatis中日志输出级别 -->
    <logger name="org.springframework.data.mongodb.core" level="DEBUG" />
    <logger name="org.mongodb.driver" level="WARN" />

    <!-- 项目代码日志级别 -->
    <logger name="com.ysyc" level="DEBUG" additivity="true" />

    <!-- 开发环境 -->
    <springProfile name="dev">
    <logger name="com.ysyc" level="DEBUG" additivity="true" />
    </springProfile>
    <!-- 生产环境 -->
    <springProfile name="prod">
    <logger name="com.ysyc" level="INFO" additivity="true" />
    </springProfile>
    <!-- 开发环境 -->
    <springProfile name="test">
    <logger name="com.ysyc" level="DEBUG" additivity="true" />
    </springProfile>

    <root level="DEBUG">
    <appender-ref ref="STDOUT" />
    <appender-ref ref="FILE" />
    </root>
    </configuration>

    参考:http://www.cnblogs.com/warking/p/5710303.html
  • 相关阅读:
    DROP,TRUNCATE 和DELETE的区别
    工作手记之Cransoft
    Java输入输出流
    上海植物园
    eclipse中开发android程序时,打开layout配置文件eclipse关闭
    Android SDK 2.2 开发环境搭建
    Android读取电话薄中的电话号码
    Android模拟器大小
    工作手记之Cransoft(二)
    工作手记之Cransoft(三)
  • 原文地址:https://www.cnblogs.com/xingzc/p/9020889.html
Copyright © 2011-2022 走看看