logging - Spring boot logback fileappender configuration -


i have simple spring boot 1.2.2 web application have created logback.xml configuration file:

<configuration debug="true" scan="true" scanperiod="33 seconds">    <appender name="console" class="ch.qos.logback.core.consoleappender">         <encoder>       <pattern>%d{hh:mm:ss.sss} [%thread] %-5level %logger{36} - %msg%n</pattern>     </encoder>   </appender>  <!--   <appender name="logfile" class="ch.qos.logback.core.fileappender">     <file>myapp.log</file>     <append>true</append>     <encoder>       <pattern>%d{hh:mm:ss.sss %-5level [%thread] %logger{10} [%file:%line] %msg%n</pattern>     </encoder>         </appender> -->    <logger name="com.myapp.logtest.samplecontroller" level="debug"/>   <logger name="com.myapp.logtest" level="warn">   </logger>    <root level="info">     <appender-ref ref="console"/>   </root>  </configuration> 

everything works great! here debug output logfile:

12:29:16,397 |-info in ch.qos.logback.classic.joran.action.configurationaction - setting reconfigureonchangefilter scanning period 33 seconds 12:29:16,397 |-info in reconfigureonchangefilter{invocationcounter=0} - scan changes in [[...\logtest\logback.xml]] every 33 seconds.  12:29:16,397 |-info in ch.qos.logback.classic.joran.action.configurationaction - adding reconfigureonchangefilter turbo filter 12:29:16,397 |-info in ch.qos.logback.core.joran.action.appenderaction - instantiate appender of type [ch.qos.logback.core.consoleappender] 12:29:16,397 |-info in ch.qos.logback.core.joran.action.appenderaction - naming appender [console] 12:29:16,407 |-info in ch.qos.logback.core.joran.action.nestedcomplexpropertyia - assuming default type [ch.qos.logback.classic.encoder.patternlayoutencoder] [encoder] property 12:29:16,427 |-info in ch.qos.logback.classic.joran.action.loggeraction - setting level of logger [com.myapp.logtest.samplecontroller] debug 12:29:16,427 |-info in ch.qos.logback.classic.joran.action.loggeraction - setting level of logger [com.myapp.logtest] warn 12:29:16,427 |-info in ch.qos.logback.classic.joran.action.rootloggeraction - setting level of root logger info 12:29:16,427 |-info in ch.qos.logback.core.joran.action.appenderrefaction - attaching appender named [console] logger[root] 12:29:16,427 |-info in ch.qos.logback.classic.joran.action.configurationaction - end of configuration. 12:29:16,427 |-info in ch.qos.logback.classic.joran.joranconfigurator@25641d39 - registering current configuration safe fallback point 

now, here problem. if uncomment file appender in configuration file, without making reference it, entire logback configuration discarded , application goes using spring logging defaults. here logback debug output file appender present:

12:32:58,308 |-info in ch.qos.logback.classic.joran.action.configurationaction - setting reconfigureonchangefilter scanning period 33 seconds 12:32:58,308 |-info in reconfigureonchangefilter{invocationcounter=0} - scan changes in [[...\logtest\logback.xml]] every 33 seconds.  12:32:58,308 |-info in ch.qos.logback.classic.joran.action.configurationaction - adding reconfigureonchangefilter turbo filter 12:32:58,308 |-info in ch.qos.logback.core.joran.action.appenderaction - instantiate appender of type [ch.qos.logback.core.consoleappender] 12:32:58,308 |-info in ch.qos.logback.core.joran.action.appenderaction - naming appender [console] 12:32:58,328 |-info in ch.qos.logback.core.joran.action.nestedcomplexpropertyia - assuming default type [ch.qos.logback.classic.encoder.patternlayoutencoder] [encoder] property 12:32:58,338 |-info in ch.qos.logback.core.joran.action.appenderaction - instantiate appender of type [ch.qos.logback.core.fileappender] 12:32:58,338 |-info in ch.qos.logback.core.joran.action.appenderaction - naming appender [logfile] 12:32:58,338 |-info in ch.qos.logback.core.joran.action.nestedcomplexpropertyia - assuming default type [ch.qos.logback.classic.encoder.patternlayoutencoder] [encoder] property 12:32:58,348 |-warn in logger[org.springframework.boot.logging.loggingapplicationlistener] - no appenders present in context [default] logger [org.springframework.boot.logging.loggingapplicationlistener]. 

as can see, mere presence of file appender causes logback initialization cease warning loggingapplicationlistener. logback instantiates file appender, believe correctly specified in logback.xml. logback.xml ignored, , logging falls spring defaults.

what warning mean? how can logback file appender work spring boot?

check if have logging.level.org.springframework.web: debug logging.level.org.hibernate: error in pplication properties. if present in application.properties logback.xml ignored , default present in application.properties.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -