我有以下Log4J XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<File name="MyFile" fileName="OutputLogFile.log" immediateFlush="false" append="false">
<PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</File>
<Flume name="AuditLogger" compress="true">
<!-- <Agent host="localhost" port="8800"/>
<RFC5424Layout enterpriseNumber="18060" includeMDC="true" appName="MyApp"/>
-->
</Flume>
<Routing name="Routing">
<Routes pattern="$${sd:type}">
<Route>
<RollingFile name="Rolling-${sd:type}" fileName="${sd:type}.log"
filePattern="${sd:type}.%i.log.gz">
<PatternLayout>
<pattern>%d %p %c{1.} [%t] %m%n</pattern>
</PatternLayout>
<SizeBasedTriggeringPolicy size="100" />
</RollingFile>
</Route>
<!-- <Route ref="AuditLogger" key="Audit"/> -->
</Routes>
</Routing>
</Appenders>
<Loggers>
<Root level="all">
<Appender-Ref ref="Console"/>
<Appender-Ref ref="MyFile"/> <!-- added_in now -->
</Root>
</Loggers>
</Configuration>
这是实现RoutingAppender的方法吗?我的目标是打破日志记录,以便当我的应用程序记录(使用logger.debug("This is debug");
)消息时,它会将日志文件分解为许多单独的日志(类似于LogOutput1.log,LogOutput2.log,LogOutput3。记录等。)
但似乎我在这里错过了这个想法。 Apache Flume不能和我合作,而且我一直都是这样做的:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/flume/Even
t
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethods(Unknown Source)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.creat
eBuilder(PluginBuilder.java:154)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build
(PluginBuilder.java:120)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPlug
inObject(AbstractConfiguration.java:766)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConf
iguration(AbstractConfiguration.java:706)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConf
iguration(AbstractConfiguration.java:698)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigur
e(AbstractConfiguration.java:358)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(Abst
ractConfiguration.java:161)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerCo
ntext.java:361)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext
.java:426)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext
.java:442)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:
138)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log
4jContextFactory.java:207)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log
4jContextFactory.java:41)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:160)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:492)
at sample_server.<clinit>(sample_server.java:26)
Caused by: java.lang.ClassNotFoundException: org.apache.flume.Event
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 19 more
非常感谢任何提示/提示,谢谢/