Spring boot logback-spring.xml无法使用目标重新打包?
我的目的首先是在特定的活动概要文件中禁用控制台输出 我已经安装了一个新的tomcat(8.5.12),并且只部署了一个“spring boot hello world”应用程序,与此类似 包装类型是经典的Spring boot logback-spring.xml无法使用目标重新打包?,spring-boot,logback,Spring Boot,Logback,我的目的首先是在特定的活动概要文件中禁用控制台输出 我已经安装了一个新的tomcat(8.5.12),并且只部署了一个“spring boot hello world”应用程序,与此类似 包装类型是经典的war——因此我将pom更改如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/
war
——因此我将pom更改如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework</groupId>
<artifactId>gs-spring-boot</artifactId>
<version>0.1.0</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<finalName>foo</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
基于此,我在启动tomcat时添加了-Dlogback.statusListenerClass=ch.qos.logback.core.status.onConsolStatusListener
。这将导致以下结果
16:22:33,891 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
16:22:33,891 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
16:22:33,891 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/tmp/apache-tomcat-8.5.12/webapps/foo/WEB-INF/classes/logback.xml]
查看指定位置,有以下文件/文件夹:
ls /tmp/apache-tomcat-8.5.12/webapps/foo/WEB-INF/classes/
hello logback-spring.xml
如果我添加例如(有效)logback-dev.xml
,我会在catalina.out
中得到以下结果:
17:44:46,698 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
17:44:46,702 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
17:44:46,703 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.xml]
logback是正常的吗?logbackspring.xml
是一个logback.xml
?或者这可能是一个错误
使用“普通”logback.xml
不允许使用,例如
请参阅
如果我想使用不同的配置文件,我找到的唯一解决方案是提供一个logback-{stage}.xml
并在相关的application-{stage}.properties
文件中添加一个logging.config=classpath:logback-{stage}.xml
,这似乎有效。也不行!我可以添加logback-{stage}.xml
而不产生任何效果。但一旦我将其包含到logging.config=classpath:logback-{stage}.xml
中,我就会得到:
09:26:35.084 [localhost-startStop-2] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [LOGGING_patternlevel]
09:26:35.084 [localhost-startStop-2] DEBUG org.springframework.jndi.JndiPropertySource - JNDI lookup for name [LOGGING_patternlevel] threw NamingException with message: Name [LOGGING_patternlevel] is not bound in this Context. Unable to find [LOGGING_patternlevel].. Returning null
09:26:35.084 [localhost-startStop-2] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [LOGGING_patternlevel]
09:26:35.084 [localhost-startStop-2] DEBUG org.springframework.jndi.JndiPropertySource - JNDI lookup for name [LOGGING_patternlevel] threw NamingException with message: Name [LOGGING_patternlevel] is not bound in this Context. Unable to find [LOGGING_patternlevel].. Returning null