我使用 spring boot 1.2.1.RELEASE 并注意到 spring 在启动时自动更改我的 log4j 配置。
这是我的(春季)依赖项:
<!-- parent includes slf4j and log4j -->
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.1.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.1.2.RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<version>1.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>de.komoot.wanderwalter</groupId>
<artifactId>wanderwalter-api-models</artifactId>
<version>1.26-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.komoot.wanderwalter</groupId>
<artifactId>wanderwalter-routing</artifactId>
<version>1.26-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.graphhopper</groupId>
<artifactId>graphhopper</artifactId>
<version>0.3-kmt</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
</dependencyManagement>
当我开始我的应用程序时-Dlog4j.configuration=log4j-live.xml -Dlog4j.debug
我可以看到,首先使用了我的 log4j 配置,然后 spring 清理它并安装它自己的配置,然后(这是我的猜测)从类路径添加默认的 log4j.xml 。
如何仅使用默认的 log4j 行为或者如何定义 spring 应使用哪些文件进行配置?
Cheers,
Jan
Spring Boot 使用与日志记录系统无关的属性来覆盖默认配置:
如果环境包含属性logging.config那么它将用于初始化日志系统,否则使用默认位置。
So use -Dlogging.config=log4j-live.xml -Dlog4j.debug
反而。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)