我正在尝试使用 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 不会有它。有人可以提供任何建议以使其正常工作吗?