Java 为什么Log4J2使用Nomad和本地所有级别只记录错误级别

Java 为什么Log4J2使用Nomad和本地所有级别只记录错误级别,java,log4j2,nomad,Java,Log4j2,Nomad,我有一个SpringBoot2.2.4应用程序,可以在本地完美运行。我可以看到需要查看的所有级别的日志 这是我的log4j2.xml文件(位于src/main/resources中) pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="htt

我有一个SpringBoot2.2.4应用程序,可以在本地完美运行。我可以看到需要查看的所有级别的日志

这是我的log4j2.xml文件(位于src/main/resources中)


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>

4.0.0
ca.示例
例子
1.0.15
罐子
同步应用程序
org.springframework.boot
spring启动程序父级
2.2.4.1发布
UTF-8
UTF-8
1.8
8.0.20
2.13.3
ca.示例
制造库
2.0.2
ca.示例
核心模型
3.2.11
ca.示例
通用模型
ca.示例
主制造模型
2.2.6
加州广告
通用模型
org.springframework.boot
弹簧靴起动器
org.springframework.boot
spring启动程序日志记录
org.springframework.boot
spring-boot-starter-log4j2
org.springframework
弹簧芯
org.springframework.boot
spring引导启动器数据jpa
org.springframework
spring上下文支持
罐子
org.springframework
弹簧网
罐子
mysql
mysql连接器java
com.fasterxml.jackson.module
jackson模块jaxb注释
org.apache.httpcomponents
httpclient
org.springframework.boot
弹簧起动试验
测试
org.junit.jupiter
朱尼特木星发动机
测试
com.h2数据库
氢
运行时
org.springframework.restdocs
SpringRestMVC
测试
org.springframework.boot
弹簧启动测试自动配置
org.junit.jupiter
JUnitJupiter api
org.springframework
弹簧试验
org.springframework.boot
弹簧启动试验
org.projectlombok
龙目
1.18.12
假如
org.springframework
SpringWebMVC
org.springframework.boot
springbootmaven插件
构建信息
我正在使用一个实用程序类来调用我的log4J2。该实用程序类位于我的pom.xml中包含的另一个项目中

我的问题是,当我在我的Nomad环境中运行我的项目时,似乎级别是覆盖的,我只得到了错误日志。启动Nomad任务时,会检测到log4j2.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>