Jakarta ee 是否可以在Tomcat中为单个webapp运行Logback?

Jakarta ee 是否可以在Tomcat中为单个webapp运行Logback?,jakarta-ee,tomcat,slf4j,logback,Jakarta Ee,Tomcat,Slf4j,Logback,我想将我的一个webapp配置为完全使用SLF4J over Logback进行日志记录。我想把Tomcat的其余部分放在一边,我只想确保在我的webapp中完成的所有日志记录(通过Spring、Hibernate、EhCache等)都是通过SLF4J通过我的webapp的Logback上下文完成的,而不是通过Tomcat的默认(JUL?)日志记录系统完成的 我注意到,在记录日志时,多个库“丢失”了SLF4J,在任何其他情况下通常都会使用SLF4J。EhCache正在使用SLF4J,但Sprin

我想将我的一个webapp配置为完全使用SLF4J over Logback进行日志记录。我想把Tomcat的其余部分放在一边,我只想确保在我的webapp中完成的所有日志记录(通过Spring、Hibernate、EhCache等)都是通过SLF4J通过我的webapp的Logback上下文完成的,而不是通过Tomcat的默认(JUL?)日志记录系统完成的

我注意到,在记录日志时,多个库“丢失”了SLF4J,在任何其他情况下通常都会使用SLF4J。EhCache正在使用SLF4J,但Spring和其他一些库正在使用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正确地使用它而其他一切都不正确?

SLF4J提供了将日志从log4j、j.u.l.和commons日志路由到SLF4J的工件。看见 该文件名为“详细信息”


Spring使用commons日志记录。幸运的是,SLF4J为名为。您只需要用jcl-over-slf4j替换commons日志依赖项。SLF4J提供了将日志从log4j、j.u.l.和commons日志路由到SLF4J的工件。看见 该文件名为“详细信息”

Spring使用commons日志记录。幸运的是,SLF4J为名为。您只需要用jcl-over-slf4j替换commons日志依赖项。这一点在本节中进行了解释