我已經搜索過stackoverflow和谷歌它很多,但我的問題還沒有解決。Logback RollingFileAdapter在Payara服務器中無法正常工作
問題:
在代碼我有這些記錄程序:
@Stateless
public class NotificatrionService implements INotificationService {
private final static Logger logger = LoggerFactory.getLogger("DEF");
private final static Logger logger_wsdlr = LoggerFactory.getLogger("wsdlr");
:
:
}
並且在某些情況下,我使用的每個一個
:
logger_wsdlr.info("Some info messages");
:
logger.debug("Some debug messages"));
:
要設置的logback與Payara Server 4
(穩定Glassfish的4),按照@vzamanillo寫在這篇文章中的說明:
cannot get SLF4J working with glassfish 4
在該指南(或其他找到的人)使用ch.qos.logback.core.FileAppender
。有了這個appender logback工作得很好,但我需要旋轉日誌文件。然後,我只是設置ch.qos.logback.core.rolling.RollingFileAppender
在我logback.xml
,就像這樣:
<configuration scan="true" debug="true">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<property name="pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level][%thread][%logger{36}]%msg%n"/>
<property name="dir" value="/tmp/log"/>
<appender name="DEF" class="ch.qos.logback.core.FileAppender">
<file>${com.sun.aas.instanceRoot}/logs/my_def.log</file>
<append>true</append>
<encoder>
<Pattern>${pattern}</Pattern>
</encoder>
</appender>
<appender name="WSDLR" class="ch.qos.logback.core.RollingFileAppender">
<file>${dir}/dt_wsdlr.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${dir}/dt_wsdlr-%d{yyyy.MM.dd}.log</fileNamePattern>
<maxHistory>90</maxHistory>
<totalSizeCap>3GB</totalSizeCap>
</rollingPolicy>
<encoder>
<Pattern>${pattern}</Pattern>
</encoder>
</appender>
<!-- appender that replace payara default server.log, defualt was redirected to ${com.sun.aas.instanceRoot}/tmp/server.log -->
<appender name="GF" class="ch.qos.logback.core.FileAppender">
<file>${com.sun.aas.instanceRoot}/logs/server.log</file>
<append>true</append>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<encoder>
<Pattern>${pattern}</Pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="GF"/>
</root>
<logger level="TRACE" name="DEF" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
<logger level="DEBUG" name="wsdlr" additivity="false">
<appender-ref ref="WSDLR"/>
</logger>
</configuration>
當我用我的代碼RollingFileAppender
參考,根本就沒有被創建相關的附加器文件和日誌只是缺少。
我嘗試從上面提到的職位(@casten post),而只是一個新的錯誤申請步驟募
2017-04-07 10:49:25.297 [ERROR][Thread-20][j.e.system.tools.deployment.common]Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NoClassDefFoundError: javax/servlet/ServletContainerInitializer
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:168)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:353)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:501)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:406)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.load(InstallerThread.java:211)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.run(InstallerThread.java:100)
2017-04-07 10:49:25.297 [ERROR][Thread-20][javax.enterprise.system.core]Exception during lifecycle processing
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NoClassDefFoundError: javax/servlet/ServletContainerInitializer
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:168)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:353)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:501)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:406)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.load(InstallerThread.java:211)
at com.sun.enterprise.v3.admin.adapter.InstallerThread.run(InstallerThread.java:100)
我剛回退瓶的位置。
任何人都可以幫助我找到正確的方式使用RollingFileAppender
?
非常感謝您提前!
請標記爲正確答案(即使是你的),以表明問題已解決。 – OndrejM
對不起,我被刪除了帖子,但是......還活着。 – Vielinko