将jmeter依赖项添加到我的pom.xml中时,获取log4j错误ERROR StatusLogger“未找到log4j2配置文件”

时间:2018-06-28 16:28:44

标签: java log4j slf4j citrus-framework

这是我的pom.xml。我遇到了log4j错误,并且在得到错误后没有任何信息可以打印,对此有任何帮助。我已经看到很多类似的问题,但都无法正常工作

 <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>com.walmart.testframrework</groupId>
      <artifactId>testframework</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <dependencies>

      <dependency>
        <groupId>org.apache.jmeter</groupId>
        <artifactId>ApacheJMeter_core</artifactId>
        <version>4.0</version>
         <exclusions> 
         <exclusion>
          <groupId>org.slf4j</groupId> 
          <artifactId>slf4j-log4j12</artifactId>
           </exclusion>
            </exclusions> 
    </dependency> 

      <dependency>
        <groupId>org.apache.jmeter</groupId>
        <artifactId>ApacheJMeter_jms</artifactId>
        <version>4.0</version>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
          <artifactId>jcl-over-slf4j</artifactId>
            </exclusion>
            <exclusion>
               <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>

            </exclusion>
        </exclusions>
    </dependency>


     <!-- <dependency>
        <groupId>com.elega9t</groupId>
        <artifactId>jmeter-jms-skip-jndi</artifactId>
        <version>0.0.1</version>
    </dependency> -->

      <dependency>
      <groupId>com.consol.citrus</groupId>
      <artifactId>citrus-java-dsl</artifactId>
      <version>2.7.3</version>
      <scope>test</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.consol.citrus/citrus-jms -->
    <dependency>
        <groupId>com.consol.citrus</groupId>
        <artifactId>citrus-jms</artifactId>
        <version>2.7.3</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>5.0.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.6</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>5.0.4.RELEASE</version>
    </dependency>
      <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>jcl-over-slf4j</artifactId>
          <version>1.7.25</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
          <version>1.7.25</version>
          <scope>test</scope>
        </dependency> 
        <dependency>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
          <version>1.2</version>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>com.consol.citrus</groupId>
          <artifactId>citrus-core</artifactId>
          <version>2.7.3</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
    </project>

在未添加jmeter依赖项之前,我的应用程序运行良好。但是添加这些依赖项后,它会显示

之类的错误
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' to show Log4j2 internal initialization logging.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file://dwshome-a.homeoffice.wal-mart.com/dwsuserdata$/avada2/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.10.0/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file://dwshome-a.homeoffice.wal-mart.com/dwsuserdata$/avada2/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

这是pom.xml中定义的jmeter依赖项

<dependency>
  <groupId>org.apache.jmeter</groupId>
  <artifactId>ApacheJMeter_core</artifactId>
    <version>4.0</version> 
</dependency> 
  <dependency>
    <groupId>org.apache.jmeter</groupId>
    <artifactId>ApacheJMeter_jms</artifactId>
    <version>4.0</version>
</dependency>
  <dependency>
    <groupId>com.elega9t</groupId>
    <artifactId>jmeter-jms-skip-jndi</artifactId>
    <version>0.0.1</version>
</dependency>

1 个答案:

答案 0 :(得分:0)

您在log4j2.xml下有<maven_module>/src/test/resources吗?

这是一个示例配置:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>

    <Properties>
        <Property name="path">target</Property>
        <Property name="logFileName">integration-tests-logs</Property>
        <Property name="logPattern">%d{HH:mm:ss,SSS} %-5.5p %28.28c{2}| %m%n</Property>
    </Properties>

    <Appenders>
        <Console name="console" target="SYSTEM_OUT">
            <PatternLayout pattern="${logPattern}"/>
        </Console>
        <File name="logfile" fileName="${path}/${logFileName}.log" append="true">
            <PatternLayout pattern="${logPattern}"/>
        </File>
    </Appenders>

    <Loggers>
        <Root level="DEBUG">
            <AppenderRef ref="console"/>
            <AppenderRef ref="logfile"/>
        </Root>
        <Logger name="org.eclipse.jetty" level="INFO" additivity="false">
            <AppenderRef ref="console"/>
        </Logger>
    </Loggers>
</Configuration>

这基本上是在控制台中配置日志记录,并在每次运行集成测试时在/target文件夹中生成一个日志文件。