赞
踩
logback.xml配置
主要就是在<appender> 不设置级别
在root节点配置info级别并引用日志文件
- <?xml version="1.0" encoding="UTF-8"?>
- <configuration scan="true" scanPeriod="60 seconds" debug="false">
- <contextName>sapflowengine service</contextName>
- <!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
-
- <!--<property name="log.path" value="/home/applogs/activiti" />-->
- <property name="log.appname" value="service" />
-
- <!-- 彩色日志 -->
- <!-- 彩色日志依赖的渲染类 -->
- <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
- <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
- <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
- <!-- 彩色日志格式 -->
- <property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}" />
-
-
- <!--输出到控制台-->
- <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
- <!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>ERROR</level>
- </filter>-->
- <encoder>
- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{72} %line - %msg%n</pattern>
- </encoder>
- </appender>
-
- <!--输出到文件 按照每天生成日志文件-->
- <appender name="fileInfo" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!--日志文件输出的文件名-->
- <fileNamePattern>${log.path}/${log.appname}/logback_info.%d{yyyy-MM-dd}.log</fileNamePattern>
- <!--日志文件保留天数-->
- <MaxHistory>30</MaxHistory>
- </rollingPolicy>
- <!--这里设置日志级别为info-->
- <!-- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <level>info</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter> -->
- <encoder>
- <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{72} %line - %msg%n</pattern>
- </encoder>
- <!--日志文件最大值-->
- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <MaxFileSize>100MB</MaxFileSize>
- </triggeringPolicy>
- </appender>
-
- <!--输出到文件 按照每天生成日志文件-->
- <appender name="fileError" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!--日志文件输出的文件名-->
- <fileNamePattern>${log.path}/${log.appname}/logback_error.%d{yyyy-MM-dd}.log</fileNamePattern>
- <!--日志文件保留天数-->
- <MaxHistory>30</MaxHistory>
- </rollingPolicy>
- <!--这里设置日志级别为info-->
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <level>info</level>
- <onMatch>ACCEPT</onMatch>
- <onMismatch>DENY</onMismatch>
- </filter>
- <encoder>
- <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{72} %line - %msg%n</pattern>
- </encoder>
- <!--日志文件最大值-->
- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <MaxFileSize>100MB</MaxFileSize>
- </triggeringPolicy>
- </appender>
-
-
-
-
- <!-- 日志输出级别 -->
- <root level="info">
- <appender-ref ref="console" />
- <appender-ref ref="fileInfo" />
- <appender-ref ref="fileError" />
- </root>
-
- <!-- 日志输出级别 -->
- <!-- <root level="debug">
- <appender-ref ref="fileInfo" />
- <appender-ref ref="fileError" />
- </root> -->
- <!-- 日志输出级别
- <root level="info">
- <appender-ref ref="console" />
- <appender-ref ref="fileInfo" />
- <appender-ref ref="fileError" />
- </root> -->
-
-
- <!-- logback为java中的包 -->
- <!-- <logger name="com.sapcisframework" level="DEBUG"/> -->
- <!-- activiti -->
- <!-- <logger name="org.activiti.engine.impl.persistence.entity" level="DEBUG"/> -->
-
- <!-- <logger name="org.hibernate.SQL"> -->
- <!-- <level value="debug"/> -->
- <!-- </logger> -->
-
- <!-- show parameters for hibernate sql 专为 Hibernate 定制 -->
- <!-- <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
- <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" /> -->
-
- <!--myibatis log configure-->
- <!-- <logger name="com.apache.ibatis" level="TRACE"/> -->
- <!-- <logger name="java.sql.Connection" level="DEBUG"/>
-
- <logger name="java.sql.Statement" level="DEBUG"/>
- <logger name="java.sql.PreparedStatement" level="DEBUG"/> -->
-
- <!--logback.LogbackDemo:类的全路径 -->
- <!-- <logger name="com.dudu.controller.LearnController" level="WARN" additivity="false"> -->
- <!-- <appender-ref ref="console"/> -->
- <!-- </logger> -->
- </configuration>
.properties里面配置
- logging.level.com.sapcis.couponticket.dao=debug
- #mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl SQL只在控制台输出 不会输出到日志文件
- mybatis.configuration.log-impl=org.apache.ibatis.logging.slf4j.Slf4jImpl
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。