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 Nicolas Bär <ni...@gmail.com> on 2014/03/07 14:22:03 UTC

Log4j2 Custom Layout Flume Appender

Hi

I'm trying to use Log4j2 to send certain log messages to Apache Flume.
Flume should then push the messages to Elasticsearch in order to analyze
the data with Kibana. The setup works fine using the JSONLayout, but this
layout does not provide enough flexibility for my use case. Currently the
message is saved to Elasticsearch as one field. Therefore I'd like to
replace the JSONLayout with a custom implementation to extract certain
fields from the log messages. I followed the instructions on the following
page: http://logging.apache.org/log4j/2.x/manual/extending.html#Layouts
But I'm not able to specify the custom layout in the log4j2.xml file.
What's the correct syntax to do this?

I tried the <layout> tag and specified my custom class in the name
attribute. This will throw the following error message: ERROR Flume
contains an invalid element or attribute "layout".

Any help is highly appreciated, thanks.

Best,
Nicolas

Re: Log4j2 Custom Layout Flume Appender

Posted by Nicolas Bär <ni...@gmail.com>.
Specifying the package name in the packages attribute of the configuration
element did the trick. Thanks!

Nicolas


On Fri, Mar 7, 2014 at 5:10 PM, Ralph Goers <ra...@dslextreme.com>wrote:

> You made your layout a plugin?  If so, make sure you specify its package
> name in the packages attribute of the configuration element.  Then specify
>
> <MyLayout attr1="" attr2=""/>
>
> Where MyLayout is the name you gave your Layout plugin and attr1 and attr2
> are attributes you defined for the layout.
>
> Log4j 2 uses plugins so you never specify the name of the class in the
> configuration.
>
> Ralph
>
> On Mar 7, 2014, at 5:22 AM, Nicolas Bär <ni...@gmail.com> wrote:
>
> > Hi
> >
> > I'm trying to use Log4j2 to send certain log messages to Apache Flume.
> > Flume should then push the messages to Elasticsearch in order to analyze
> > the data with Kibana. The setup works fine using the JSONLayout, but this
> > layout does not provide enough flexibility for my use case. Currently the
> > message is saved to Elasticsearch as one field. Therefore I'd like to
> > replace the JSONLayout with a custom implementation to extract certain
> > fields from the log messages. I followed the instructions on the
> following
> > page: http://logging.apache.org/log4j/2.x/manual/extending.html#Layouts
> > But I'm not able to specify the custom layout in the log4j2.xml file.
> > What's the correct syntax to do this?
> >
> > I tried the <layout> tag and specified my custom class in the name
> > attribute. This will throw the following error message: ERROR Flume
> > contains an invalid element or attribute "layout".
> >
> > Any help is highly appreciated, thanks.
> >
> > Best,
> > Nicolas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: Log4j2 Custom Layout Flume Appender

Posted by Ralph Goers <ra...@dslextreme.com>.
You made your layout a plugin?  If so, make sure you specify its package name in the packages attribute of the configuration element.  Then specify

<MyLayout attr1=“” attr2=“”/>

Where MyLayout is the name you gave your Layout plugin and attr1 and attr2 are attributes you defined for the layout.

Log4j 2 uses plugins so you never specify the name of the class in the configuration.

Ralph

On Mar 7, 2014, at 5:22 AM, Nicolas Bär <ni...@gmail.com> wrote:

> Hi
> 
> I'm trying to use Log4j2 to send certain log messages to Apache Flume.
> Flume should then push the messages to Elasticsearch in order to analyze
> the data with Kibana. The setup works fine using the JSONLayout, but this
> layout does not provide enough flexibility for my use case. Currently the
> message is saved to Elasticsearch as one field. Therefore I'd like to
> replace the JSONLayout with a custom implementation to extract certain
> fields from the log messages. I followed the instructions on the following
> page: http://logging.apache.org/log4j/2.x/manual/extending.html#Layouts
> But I'm not able to specify the custom layout in the log4j2.xml file.
> What's the correct syntax to do this?
> 
> I tried the <layout> tag and specified my custom class in the name
> attribute. This will throw the following error message: ERROR Flume
> contains an invalid element or attribute "layout".
> 
> Any help is highly appreciated, thanks.
> 
> Best,
> Nicolas


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