问题描述
我有一个在本地完美运行的spring boot 2.2.4应用程序。我可以看到所有级别的日志。
这是我的log4j2.xml文件(位于src / main / resources中)
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO" name="loggerConfiguration" shutdownHook="disable">
<Appenders>
<Console name="console" target="SYstem_OUT">
<PatternLayout pattern="TEST %d{yyyy-MM-dd HH:mm:ss} %-5p %m%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="console"/>
</Root>
</Loggers>
</Configuration>
pom.xml
<?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>ca.example</groupId>
<artifactId>example</artifactId>
<version>1.0.15</version>
<packaging>jar</packaging>
<name>Sync-app</name>
<description></description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<mysql-connector.version>8.0.20</mysql-connector.version>
<log4j2.version>2.13.3</log4j2.version>
</properties>
<dependencies>
<!-- ******************************************** -->
<!-- ******************* ADS ******************** -->
<!-- ******************************************** -->
<dependency>
<groupId>ca.example</groupId>
<artifactId>manufacture-library</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>ca.example</groupId>
<artifactId>core-model</artifactId>
<version>3.2.11</version>
<exclusions>
<exclusion>
<groupId>ca.example</groupId>
<artifactId>generic-model</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ca.example</groupId>
<artifactId>master-manufacture-model</artifactId>
<version>2.2.6</version>
<exclusions>
<exclusion>
<groupId>ca.ads</groupId>
<artifactId>generic-model</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- ******************************************** -->
<!-- **************** SPRINGBOOT **************** -->
<!-- ******************************************** -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<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-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>MysqL</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<!-- ******************************************** -->
<!-- ****************** TEST ******************** -->
<!-- ******************************************** -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
</dependency>
<!-- ******************************************** -->
<!-- **************** OTHERS ******************** -->
<!-- ******************************************** -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我正在使用实用程序类来调用我的log4J2。该实用程序类位于我的pom.xml中包含的另一个项目中。
我的问题是当我在Nomad环境中运行项目时,似乎级别已被覆盖,并且我仅收到错误日志。启动我的Nomad任务时,将检测到log4j2.xml。
因此,我需要您的帮助来确定覆盖的位置以及如何使它起作用。 谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)