构建aws athena项目时,log4j出现错误

时间:2018-10-22 07:00:37

标签: java log4j aws-sdk amazon-athena

当我使用aws athena sdk,aws java athena sdk,log4j构建项目时,我失败了。 这是消息

log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "com.simba.athena.shaded.apache.log4j.Appender" variable.
log4j:ERROR The class "com.simba.athena.shaded.apache.log4j.Appender" was 
loaded by 
log4j:ERROR [sun.misc.Launcher$AppClassLoader@18b4aac2] whereas object of type 
log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [sun.misc.Launcher$AppClassLoader@18b4aac2].
log4j:ERROR Could not instantiate appender named "A1".

这是我的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>Athena</groupId>
<artifactId>Athena</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-athena -->
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-athena</artifactId>
        <version>1.11.433</version>
    </dependency>


</dependencies>

和我的log4j.properties

log4j.rootLogger=WARN, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c -  %m%n
# Turn on DEBUG logging in com.amazonaws.request to log
# a summary of requests/responses with AWS request IDs
log4j.logger.com.amazonaws.request=DEBUG

非常感谢

1 个答案:

答案 0 :(得分:0)

请尝试使用以下log4j.properties

### Appender
log4j.appender.stdout=com.simba.athena.shaded.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=com.simba.athena.shaded.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
### Log Levels
log4j.rootLogger=info, stdout

依赖项:

        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>athena</artifactId>
            <version>2.13.3</version>
        </dependency>

        <dependency>
            <groupId>com.syncron.amazonaws</groupId>
            <artifactId>simba-athena-jdbc-driver</artifactId>
            <version>2.0.2</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>