logback配置 -- log文件路径输出

1、使用slf4j的log形式 : private static Logger logger = LoggerFactory.getLogger(Class.class);

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
		<encoder>
			<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
		</encoder>
	</appender>

	<appender name="rollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${catalina.base}/logs/carmall-manager.log</file>//主要是这个路径
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
			<fileNamePattern>${catalina.base}/logs/carmall-manager.%d{yyyy-MM-dd}.log</fileNamePattern>
		</rollingPolicy>
		<encoder>
			<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
		</encoder>
	</appender>

	<!-- project default level -->
	<logger name="cn.iautos.manager" level="INFO" />

	<!--log4jdbc -->
	<logger name="jdbc.sqltiming" level="debug"/>

	<root level="info">
		<appender-ref ref="console" />
		<appender-ref ref="rollingFile" />
	</root>
</configuration>

 

 

posted @ 2014-02-17 16:55  prison  阅读(3324)  评论(0编辑  收藏  举报