首页 > 代码库 > 使用slf4j的时候,部署后,只有tomcat控制台有日志,没有每日日志,后台报错ROLLINGFILE

使用slf4j的时候,部署后,只有tomcat控制台有日志,没有每日日志,后台报错ROLLINGFILE

3:20:00,593 |-ERROR in ch.qos.logback.core.rolling.RollingFileAppender[ROLLINGFILE] - Appender [ROLLINGFILE] failed to append. java.nio.channels.OverlappingFileLockException
at java.nio.channels.OverlappingFileLockException
at at sun.nio.ch.SharedFileLockTable.checkList(FileLockTable.java:255)
at at sun.nio.ch.SharedFileLockTable.add(FileLockTable.java:152)
at at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:1063)
at at java.nio.channels.FileChannel.lock(FileChannel.java:1053)
at at ch.qos.logback.core.FileAppender.safeWrite(FileAppender.java:229)
at at ch.qos.logback.core.FileAppender.writeOut(FileAppender.java:254)
at at ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:212)
at at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(RollingFileAppender.java:228)
at at ch.qos.logback.core.OutputStreamAppender.append(OutputStreamAppender.java:100)
at at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(UnsynchronizedAppenderBase.java:84)
at at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48)
at at ch.qos.logback.classic.Logger.appendLoopOnAppenders(Logger.java:270)
at at ch.qos.logback.classic.Logger.callAppenders(Logger.java:257)
at at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421)
at at ch.qos.logback.classic.Logger.filterAndLog_2(Logger.java:414)
at at ch.qos.logback.classic.Logger.info(Logger.java:587)
at at com.lsxy.app.uusd.task.QiXunTongMassTaskLogTask.checkUserMassTask(QiXunTongMassTaskLogTask.java:50)
at at com.lsxy.app.uusd.task.QiXunTongMassTaskLogTask.hour(QiXunTongMassTaskLogTask.java:40)
at at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at at java.lang.reflect.Method.invoke(Method.java:498)
at at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
at at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
at at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at at java.lang.Thread.run(Thread.java:745)

 

看了下配置

 

<!-- 按照每天生成日志文件 -->
<appender name="ROLLINGFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<Prudent>true</Prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/${APP_NAME}-%d{yyyy-MM-dd}.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
<!--日志文件最大的大小-->
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>2GB</MaxFileSize>
</triggeringPolicy>
</appender>

没发现问题,后面发现少定义了

<property name="APP_NAME" value="http://www.mamicode.com/app.message.uc" />
<property name="systemId" value="http://www.mamicode.com/app.message.uc" />
<include resource="logback-yunhuni.xml"/>
<logger name="com.lsxy" level="DEBUG" additivity="true" />
<logger name="org.springframework" level="INFO" additivity="true" />
<logger name="com.lsxy.framework.web.utils.WebUtils" level="INFO" additivity="true" />


总结这个问题:看看是不是配置日志的文件漏写了什么吧~

使用slf4j的时候,部署后,只有tomcat控制台有日志,没有每日日志,后台报错ROLLINGFILE