You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Julian Keppel <ju...@gmail.com> on 2016/05/04 19:43:24 UTC

Flume appender: Dependency problem when building with maven assembly plugin?

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

Re: Flume appender: Dependency problem when building with maven assembly plugin?

Posted by Matt Sicker <bo...@gmail.com>.
By uber jar, do you mean an all-in-one flat jar, or do you mean a jar of
jars like spring boot artifacts?

On 4 May 2016 at 14:43, Julian Keppel <ju...@gmail.com> 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
>



-- 
Matt Sicker <bo...@gmail.com>

Re: Flume appender: Dependency problem when building with maven assembly plugin?

Posted by Ralph Goers <ra...@dslextreme.com>.
That would make it easier but you would still have to add something in the maven build to create the file. So I am not really sure it matters how easy or hard it is.  We should just supply whatever it is as a Maven plugin.

Ralph

> On May 11, 2016, at 11:38 AM, Matt Sicker <bo...@gmail.com> wrote:
> 
> It might be nice to make an updated plugin cache format that can be cat'd
> together instead of deserializing and serializing again.
> 
> On 11 May 2016 at 06:08, Ralph Goers <ra...@dslextreme.com> wrote:
> 
>> Oops. I think I misread your comment. You want to use the Transformer as
>> part of the maven build, not at runtime.
>> 
>> Ralph
>> 
>>> On May 11, 2016, at 3:48 AM, Julian Keppel <ju...@gmail.com>
>> wrote:
>>> 
>>> 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 <ra...@dslextreme.com>:
>>> 
>>>> 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 <
>> juliankeppel1991@gmail.com>
>>>>> 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
>>>> 
>>>> 
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> 
>> 
> 
> 
> -- 
> Matt Sicker <bo...@gmail.com>



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Flume appender: Dependency problem when building with maven assembly plugin?

Posted by Matt Sicker <bo...@gmail.com>.
It might be nice to make an updated plugin cache format that can be cat'd
together instead of deserializing and serializing again.

On 11 May 2016 at 06:08, Ralph Goers <ra...@dslextreme.com> wrote:

> Oops. I think I misread your comment. You want to use the Transformer as
> part of the maven build, not at runtime.
>
> Ralph
>
> > On May 11, 2016, at 3:48 AM, Julian Keppel <ju...@gmail.com>
> wrote:
> >
> > 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 <ra...@dslextreme.com>:
> >
> >> 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 <
> juliankeppel1991@gmail.com>
> >>> 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
> >>
> >>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
Matt Sicker <bo...@gmail.com>

Re: Flume appender: Dependency problem when building with maven assembly plugin?

Posted by Ralph Goers <ra...@dslextreme.com>.
Oops. I think I misread your comment. You want to use the Transformer as part of the maven build, not at runtime.

Ralph

> On May 11, 2016, at 3:48 AM, Julian Keppel <ju...@gmail.com> wrote:
> 
> 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 <ra...@dslextreme.com>:
> 
>> 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 <ju...@gmail.com>
>>> 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
>> 
>> 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Flume appender: Dependency problem when building with maven assembly plugin?

Posted by Ralph Goers <ra...@dslextreme.com>.
Yes. You have to aggregate all the plugin definitions from each jar into one file and then include that file in your uber jar.

Ralph

> On May 11, 2016, at 3:48 AM, Julian Keppel <ju...@gmail.com> wrote:
> 
> 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 <ra...@dslextreme.com>:
> 
>> 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 <ju...@gmail.com>
>>> 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
>> 
>> 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Flume appender: Dependency problem when building with maven assembly plugin?

Posted by Julian Keppel <ju...@gmail.com>.
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 <ra...@dslextreme.com>:

> 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 <ju...@gmail.com>
> 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
>
>

Re: Flume appender: Dependency problem when building with maven assembly plugin?

Posted by Ralph Goers <ra...@dslextreme.com>.
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 <ju...@gmail.com> 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