log4j2和jetty服务器上的flume

0sgqnhkj  于 2021-06-04  发布在  Flume
关注(0)|答案(1)|浏览(452)

我正在尝试使用log4j2和flume ng对分布式系统进行集中式日志记录。系统中的一个服务器运行jetty,我正在使用它为系统执行web服务(servlet)。当我在这个项目中包含log4j2和flume ng的maven依赖项时,它会破坏jetty,并且不会正确启动/绑定。如果我删除下面列表中的依赖项(log4j flume ng),那么jetty将正常运行,并提供以下输出:

2012-10-08 16:36:33.457::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2012-10-08 16:36:34.285 INFO net.spy.memcached.MemcachedConnection:  Added {QA sa=gs-adhoc1-test.jrs-software.co.uk/10.1.1.161:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2012-10-08 16:36:34.290 INFO net.spy.memcached.MemcachedConnection:  Connection state changed for sun.nio.ch.SelectionKeyImpl@31ac05
2012-10-08 16:36:34.272::INFO:  jetty-7.0.0.pre5
2012-10-08 16:36:34.322::INFO:  Started SelectChannelConnector@0.0.0.0:5000

但是在中有了这个依赖关系,它就变成了(只是memcached输出):

2012-10-08 16:36:34.285 INFO net.spy.memcached.MemcachedConnection:  Added {QA sa=gs-adhoc1-test.jrs-software.co.uk/10.1.1.161:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2012-10-08 16:36:34.290 INFO net.spy.memcached.MemcachedConnection:  Connection state changed for sun.nio.ch.SelectionKeyImpl@31ac05

maven pom中的依赖关系如下:

<dependencies>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty</artifactId>
        <version>3.5.4.Final</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty</artifactId>
        <version>7.0.0.pre5</version>       
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>3.0-alpha-1</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>net.sf.json-lib</groupId>
        <artifactId>json-lib</artifactId>
        <version>2.3</version>
        <classifier>jdk15</classifier>
        <exclusions>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>net.sf.ezmorph</groupId>
        <artifactId>ezmorph</artifactId>
        <version>1.0.6</version>
    </dependency>  

    <dependency>
        <groupId>couchdb4j</groupId>
        <artifactId>couchdb4j</artifactId>
        <version>0.5.0-i386-1</version>
    </dependency>

    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20090211</version>
    </dependency>

    <dependency>
        <groupId>com.google.code.simple-spring-memcached</groupId>
        <artifactId>spymemcached</artifactId>
        <version>2.8.1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.0-beta1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.0-beta1</version>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-flume-ng</artifactId>
        <version>2.0-alpha2</version>       
    </dependency>
</dependencies>

我不知道怎么开始解决这个问题。我已经设法让flume与我的其他服务器工作没有问题,但看来jetty将没有它。有人能给我一些建议让它工作吗?

yr9zkbsy

yr9zkbsy1#

我最近在我的项目中使用了jetty-6.1.26和log4j2。似乎您错过了log4j2jcl来桥接来自其他包的commons日志记录,而不是将其排除在外。没有它我就不能开始我的项目。您需要定义commons-logging.properties来使用log4j2实现,并确保它首先出现在类路径中。

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

log4j2仍然是beta2,并且在commons日志中有一个已知的bug,我发现它在beta3中已经修复了,但是不确定它何时发布。

相关问题