赞
踩
<springProfile name="dev">
<logger name="com.su.flux" level="info" additivity="false">
<appender-ref ref="stdout" />
</logger>
</springProfile>
<springProfile name="default">
<logger name="com.su.flux" level="info" additivity="false">
<appender-ref ref="infoAppender" />
</logger>
</springProfile>
在logback.xml中增加springProperty这一行读取spring配置文件中的log.fileName配置项,就可以在下面使用${}的形式引用这个变量了。
<!-- 配置参数logFile读取application.yml中的log.fileName属性,如果没有配置,默认info --> <springProperty scope="context" name="logFileName" source="log.fileName" defaultValue="info" /> <appender name="infoAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${LogHome}/info/${logFileName}.log</file> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>INFO</level><!--生产环境可以级别设置成INFO或者更高,调试环境下设置成DEBUG--> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${LogHome}/temp/info/${logFileName}.%d{yyyy-MM-dd}.%i.log</fileNamePattern> <maxHistory>15</maxHistory> <maxFileSize>100MB</maxFileSize> <totalSizeCap>2GB</totalSizeCap> </rollingPolicy> <encoder> <pattern>${LogPattern}</pattern> <charset>utf-8</charset> </encoder> </appender>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。