2017-04-18 30 views
0

Spring Boot Documentationとしてlogback-spring.xmlを構成しました。ここに私のlogback-spring.xmlファイルがLogback + springPropertyを使用したSpringブート

<configuration> 

    <springProperty name="appName" source="spring.application.name" defaultValue="myLogFile" /> 

    <property name="log.date" value="%d{yyyy-MM-dd}" /> 
    <property name="log.path" value="/log" /> 
    <property name="log.file" value="${appName}" /> 
    <property name="log.live.path" value="${log.path}/${log.file}.log" /> 

    <appender name="myLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"> 
     <file>${log.live.path}</file> 
     <append>true</append> 
     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> 
      <fileNamePattern>${log.path}/archive/${log.file}.${log.date}.log.gz</fileNamePattern> 
      <maxHistory>1</maxHistory> 
     </rollingPolicy> 
    </appender> 

    <logger name="com.log.logback" level="INFO" /> 
    <logger name="com.log.sample" level="INFO" /> 

    <root level="ERROR"> 
     <appender-ref ref="myLogAppender" /> 
    </root> 
</configuration> 

application.properties

spring.application.name=mybootapp 

であり、私は私の春のブートアプリケーションを起動している間、私はmyLogFilebootstrapある/logパスの下に作成された2つのディレクトリを参照してください。ログから、ログバックがspringプロパティにアクセスする前にブートストラップディレクトリが作成されているのがわかりました。私は、ブートストラップディレクトリが作成される理由を知りません。私は<springProperty>をlogback xmlで使用する前に、この問題を確認しませんでした。私がここで欠けている設定はありますか?私は関連する情報をオンラインで見つけることができませんでした。

参照のログ・ログ。

15:54:02,085 |-INFO in [email protected] - URL [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml] is not of type file 
15:54:02,132 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml] 
15:54:02,132 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 5 minutes 
15:54:02,132 |-WARN in Logger[org.springframework.core.env.PropertySourcesPropertyResolver] - No appenders present in context [default] for logger [org.springframework.core.env.PropertySourcesPropertyResolver]. 
15:54:02,274 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender] 
15:54:02,274 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [myLogAppender] 
15:54:02,305 |-INFO in [email protected] - Will use gz compression 
15:54:02,305 |-INFO in [email protected] - Will use the pattern /log/archive/bootstrap.%d{yyyy-MM-dd}.log for the active file 
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern '/log/archive/bootstrap.%d{yyyy-MM-dd}.log.gz'. 
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight. 
15:54:02,305 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Apr 18 15:45:05 EDT 2017 
15:54:02,320 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - Active log file name: /log/bootstrap.log 
15:54:02,320 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - File property is set to [/log/bootstrap.log] 
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.logback] to INFO 
15:54:02,336 |-INFO in [email protected] - Propagating INFO level on Logger[com.log.logback] onto the JUL framework 
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.sample] to INFO 
15:54:02,336 |-INFO in [email protected] - Propagating INFO level on Logger[com.log.sample] onto the JUL framework 
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR 
15:54:02,336 |-INFO in [email protected] - Propagating ERROR level on Logger[ROOT] onto the JUL framework 
15:54:02,336 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [myLogAppender] to Logger[ROOT] 
15:54:02,336 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 
15:54:02,336 |-INFO in org.s[email protected]26abb146 - Registering current configuration as safe fallback point 
15:54:03,139 |-INFO in [email protected] - URL [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml] is not of type file 
15:54:03,139 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [jar:file:/C:/projects/jars/logback-logging-17.2.2.INT.jar!/logback-spring.xml] 
15:54:03,139 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 5 minutes 
15:54:03,139 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender] 
15:54:03,139 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [myLogAppender] 
15:54:03,139 |-INFO in [email protected] - Will use gz compression 
15:54:03,139 |-INFO in [email protected] - Will use the pattern /log/archive/mybootapp.%d{yyyy-MM-dd}.log for the active file 
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'yyyy-MM-dd' from file name pattern '/log/archive/mybootapp.%d{yyyy-MM-dd}.log.gz'. 
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight. 
15:54:03,140 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Apr 18 15:53:03 EDT 2017 
15:54:03,140 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - Active log file name: /log/mybootapp.log 
15:54:03,140 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[myLogAppender] - File property is set to [/log/mybootapp.log] 
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.logback] to INFO 
15:54:03,140 |-INFO in [email protected] - Propagating INFO level on Logger[com.log.logback] onto the JUL framework 
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.log.sample] to INFO 
15:54:03,140 |-INFO in [email protected] - Propagating INFO level on Logger[com.log.sample] onto the JUL framework 
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR 
15:54:03,140 |-INFO in [email protected] - Propagating ERROR level on Logger[ROOT] onto the JUL framework 
15:54:03,140 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [myLogAppender] to Logger[ROOT] 
15:54:03,140 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration. 
15:54:03,140 |-INFO in org.s[email protected]45cff11c - Registering current configuration as safe fallback point 

誰かが助けてもらえますか?

答えて

3

カスタムlogback-spring.xmlを使用している場合、アプリケーションプロパティファイルではなく、ブートストラップにspring.application.nameを渡す必要があります。さもなければあなたのカスタムログバックファイルは特性を正しく読まないでしょう。それは質問とは何の関係もありません...唯一の関連春の雲にhttp://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html

+0

bootstrap.yml使用する必要があります:あなたは

参照をbootstrap.ymlにspring.application.nameを設定する必要があり

ここに。 – tomerz

+0

私は自分のapplication.propertiesをbootstrap.propertiesに変更しました。 –

関連する問題