2013-07-24 59 views
1

我使用的logback 1.0.0,我有我的應用程序中對根命名日誌文件夾,它包含一個日誌文件名爲mypp.log我logback.xml配置如下:的logback不寫入日誌文件,如果文件路徑是相對

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <appender name="STDOUT" 
      class="ch.qos.logback.core.ConsoleAppender"> 
     <layout class="ch.qos.logback.classic.PatternLayout"> 
      <pattern>[%thread] %-5level %logger{36} - %msg%n</pattern> 
     </layout> 
    </appender> 


     <!--Daily rolling file appender --> 
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> 
     <File>logs\myapp.log</File> 

     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
      <!-- daily rollover --> 
      <FileNamePattern>logs\logFile.%d{yyyy-MM-dd}.%i.log</FileNamePattern> 
      <timeBasedFileNamingAndTriggeringPolicy 
       class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> 
       <!-- or whenever the file size reaches 100MB --> 
       <maxFileSize>50MB</maxFileSize> 
      </timeBasedFileNamingAndTriggeringPolicy> 
      <!-- keep 30 days' worth of history --> 
      <maxHistory>30</maxHistory> 
     </rollingPolicy> 

     <layout class="ch.qos.logback.classic.PatternLayout"> 
      <pattern>[%thread] %-5level %logger{36} - %msg%n</pattern> 
     </layout> 

    </appender> 


    <logger name="com.myapp"> 
     <level value="debug" /> 
    </logger> 


    <root> 
     <level value="error" /> 
     <appender-ref ref="STDOUT" /> 
     <appender-ref ref="FILE" /> 
    </root> 

</configuration> 

它記錄細到控制檯,但它不記錄到文件,除非我改變的文件路徑是絕對 請告知如何解決這個問題。

回答

1

我誤會,日誌文件夾和文件已成功創建bin文件夾內jboss