我想配置我的一個webapps來完全使用SLF4J而不是Logback進行日誌記錄。我想單獨留下Tomcat的其餘部分,我只想確保在我的webapp(通過Spring,Hibernate,EhCache等)完成的所有日誌記錄都是通過SLF4J通過Logback上下文爲webapp完成的,而不是通過Tomcat的默認(JUL?)日誌系統。是否可以在Tomcat中爲單個webapp運行Logback?
我注意到,在任何其他情況下,通常會使用SLF4J時,多個庫「缺少」SLF4J。的Ehcache 是使用SLF4J,但春季和其他一些圖書館正在使用JUL,而忽略SLF4J:
Jul 13, 2012 11:25:45 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'spring'
Jul 13, 2012 11:25:45 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring': initialization started
Jul 13, 2012 11:25:45 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Fri Jul 13 11:25:45 PDT 2012]; root of context hierarchy
Jul 13, 2012 11:25:45 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
...
Jul 13, 2012 11:25:45 AM org.springframework.cache.ehcache.EhCacheManagerFactoryBean afterPropertiesSet
INFO: Initializing EHCache CacheManager
11:25:45.795 [pool-2-thread-1] DEBUG net.sf.ehcache.config.ConfigurationFactory - Configuring ehcache from InputStream
11:25:45.808 [pool-2-thread-1] DEBUG net.sf.ehcache.config.BeanHandler - Ignoring ehcache attribute xmlns:xsi
11:25:45.808 [pool-2-thread-1] DEBUG net.sf.ehcache.config.BeanHandler - Ignoring ehcache attribute xsi:noNamespaceSchemaLocation
11:25:45.809 [pool-2-thread-1] DEBUG net.sf.ehcache.config.DiskStoreConfiguration - Disk Store Path: /tmp/ehcache
11:25:45.828 [pool-2-thread-1] DEBUG net.sf.ehcache.config.ConfigurationHelper - No CacheManagerEventListenerFactory class specified. Skipping...
11:25:45.847 [pool-2-thread-1] DEBUG net.sf.ehcache.Cache - No BootstrapCacheLoaderFactory class specified. Skipping...
11:25:45.847 [pool-2-thread-1] DEBUG net.sf.ehcache.Cache - CacheWriter factory not configured. Skipping...
11:25:45.847 [pool-2-thread-1] DEBUG net.sf.ehcache.config.ConfigurationHelper - No CacheExceptionHandlerFactory class specified. Skipping...
11:25:45.849 [pool-2-thread-1] DEBUG net.sf.ehcache.Cache - No BootstrapCacheLoaderFactory class specified. Skipping...
11:25:45.849 [pool-2-thread-1] DEBUG net.sf.ehcache.Cache - CacheWriter factory not configured. Skipping...
11:25:45.849 [pool-2-thread-1] DEBUG net.sf.ehcache.config.ConfigurationHelper - No CacheExceptionHandlerFactory class specified. Skipping...
11:25:45.866 [pool-2-thread-1] DEBUG net.sf.ehcache.store.MemoryStore - Initialized net.sf.ehcache.store.NotifyingMemoryStore for encodingJobDetails.cache
11:25:45.869 [pool-2-thread-1] DEBUG net.sf.ehcache.Cache - Initialised cache: encodingJobDetails.cache
Jul 13, 2012 11:25:45 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/check/{id}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.tkassembled.model.JobDetails com.tkassembled.controller.JobController.check(java.lang.String)
Jul 13, 2012 11:25:45 AM org.springframework.web.servlet.handler.AbstractHandlerMethodMapping registerHandlerMethod
INFO: Mapped "{[/submit],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.tkassembled.model.JobTicket com.tkassembled.controller.JobController.submit(com.tkassembled.model.Job)
Jul 13, 2012 11:25:46 AM org.springframework.oxm.jaxb.Jaxb2Marshaller createJaxbContextFromContextPath
INFO: Creating JAXBContext with context path [com.tkassembled.model]
Jul 13, 2012 11:25:46 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring': initialization completed in 939 ms
Jul 13, 2012 11:25:46 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-9080"]
我怎樣才能讓所有SLF4J能力的庫使用的logback?爲什麼EhCache正確使用它,而其他一切都不正確?