logback - embedded tomcat valve spring boot -


i'm trying configure logbackvalve getting access logs in case spring boot based web application running embedded tomcat. following code configuration:

import javax.servlet.servlet;  import org.apache.catalina.startup.tomcat; import org.springframework.beans.factory.annotation.value; import org.springframework.boot.autoconfigure.condition.conditionalonclass; import org.springframework.boot.autoconfigure.condition.conditionalonproperty; import org.springframework.boot.autoconfigure.condition.conditionalonbean; import org.springframework.boot.context.embedded.tomcat.tomcatembeddedservletcontainerfactory; import org.springframework.context.annotation.bean; import org.springframework.context.annotation.configuration;  import ch.qos.logback.access.tomcat.logbackvalve;  @configuration public class embeddedtomcatconfigurator {      @bean     @conditionalonclass({ servlet.class, tomcat.class })     @conditionalonbean(value = logbackvalve.class)     public tomcatembeddedservletcontainerfactory tomcatembeddedservletcontainerfactory(logbackvalve logbackvalve) {         tomcatembeddedservletcontainerfactory factory = new tomcatembeddedservletcontainerfactory();         factory.addcontextvalves(logbackvalve);         return factory;     }      @bean     @conditionalonproperty(name = "embedded.tomcat.logback.access.config.path")     public logbackvalve logbackvalve(@value("${embedded.tomcat.logback.access.config.path:}") string filename) {         logbackvalve logbackvalve = new logbackvalve();         logbackvalve.setfilename(filename);         return logbackvalve;     } } 

however, everytime start application using "mvn spring-boot:run" in debug mode, see logs saying, "logbackvalve not found" when trying create instance of "tomcatembeddedservletcontainerfactory" bean. however, log statement indicates creation of bean. due this, initializes bean defined in auto-configuration class "org.springframework.boot.autoconfigure.web.embeddedservletcontainerautoconfiguration".

for now, i've modified class :

import javax.servlet.servlet;  import org.apache.catalina.startup.tomcat; import org.springframework.beans.factory.annotation.value; import org.springframework.boot.autoconfigure.condition.conditionalonclass; import org.springframework.boot.autoconfigure.condition.conditionalonproperty; import org.springframework.boot.context.embedded.tomcat.tomcatembeddedservletcontainerfactory; import org.springframework.context.annotation.bean; import org.springframework.context.annotation.configuration;  import ch.qos.logback.access.tomcat.logbackvalve;  @configuration public class embeddedtomcatconfigurator {      @bean     @conditionalonclass({ servlet.class, tomcat.class })     @conditionalonproperty(name = "embedded.tomcat.logback.access.config.path")     public tomcatembeddedservletcontainerfactory tomcatembeddedservletcontainerfactory(@value("${embedded.tomcat.logback.access.config.path:}") string logbackaccesspath) {         tomcatembeddedservletcontainerfactory factory = new tomcatembeddedservletcontainerfactory();         factory.addcontextvalves(getlogbackvalve(logbackaccesspath));         return factory;     }      private logbackvalve getlogbackvalve(string filename) {         logbackvalve logbackvalve = new logbackvalve();         logbackvalve.setfilename(filename);         return logbackvalve;     }  } 

i've asked question on git , has been resolved. but, here, point i'm trying bring is, why @conditionalonbean(value = logbackvalve.class) isn't detecting bean, has been defined well.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -