Thanks.

So this seems to be a general problem with log4j and the provided plugins?
But what is the right way to use log4j plugins with a maven project which
should be shipped as a complete package (JAR)? I mean, everytime you need
to use a log4j plugin, you also have at least the log4j core dependency in
you classpath. Do I really need to use a Transformer or something like that?

2016-05-05 2:00 GMT+02:00 Ralph Goers <[email protected]>:

> You are most likely having this problem because when you create your uber
> jar you can only include one of the Log4j2Plugins.dat files. Both the
> log4j2-core jar and the log4j2-flume jar are going to have one.  This has
> been discussed in https://issues.apache.org/jira/browse/LOG4J2-1059 <
> https://issues.apache.org/jira/browse/LOG4J2-1059> (which probably can be
> closed), https://issues.apache.org/jira/browse/LOG4J2-369 <
> https://issues.apache.org/jira/browse/LOG4J2-369>, and
> https://issues.apache.org/jira/browse/LOG4J2-673 <
> https://issues.apache.org/jira/browse/LOG4J2-673>.  This last one has a
> solution in the middle of the discussion by way of a Transformer that can
> be used in the maven shade plugin. However, you are using the assembly
> plugin, so I am not really sure how you can do it that way.
>
> Ralph
>
>
>
>
> > On May 4, 2016, at 12:43 PM, Julian Keppel <[email protected]>
> wrote:
> >
> > Hi everyone,
> >
> > I tested the flume appender for log4j2. My configuration XML looks like
> > this:
> >
> > <Configuration status="ERROR" name="some_name">
> >
> >    ...
> >
> >    <Appenders>
> >
> >         ...
> >
> >        <Flume name="FLUME" compress="true">
> >        <Agent host="${FLUME_HOST}" port="${FLUME_PORT}"/>
> >        <PatternLayout pattern="${LOG_PATTERN}"/>
> >        <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
> >        </Flume>
> >    </Appenders>
> >
> >    <Loggers>
> >        <Root level="DEBUG">
> >                <AppenderRef ref="FLUME"/>
> >            ...
> >        </Root>
> >    </Loggers>
> > </Configuration>
> >
> > And I build my application with maven assembly plugin to get an uber jar
> > which contains all dependencies (I want to ship a single jar file to all
> > the destination runtime environments).
> >
> > When I start the application I get the following error:
> > ERROR Error processing element Flume ([Appenders: null]): CLASS_NOT_FOUND
> >
> > So it looks like there is some dependency missing. But in the official
> doc
> > I read that for remote mode of the flume appender I only need the
> following
> > dependency (including the necessary log4j dependencies):
> >
> > <dependencies>
> >
> >                ...
> >
> > <dependency>
> > <groupId>org.apache.logging.log4j</groupId>
> > <artifactId>log4j-core</artifactId>
> > <version>2.5</version>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.logging.log4j</groupId>
> > <artifactId>log4j-api</artifactId>
> > <version>2.5</version>
> > </dependency>
> > <dependency>
> > <groupId>org.apache.logging.log4j</groupId>
> > <artifactId>*log4j-flume-ng*</artifactId>
> > <version>2.5</version>
> > </dependency>
> > </dependencies>
> >
> > Another hint: When I start the application from eclipse, it seems to work
> > totally fine (at least I don't get the error from above).
> >
> > So what I am doing wrong here? Has anyone some advice for me? Thanks in
> > advance.
> >
> > Julian
>
>

Reply via email to