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 "Zabicki Roman (HERE/Chicago)" <ro...@here.com> on 2014/03/21 20:30:18 UTC

configuring a non-core appender in log4j2

Hi,

I want to use a non-core appender with log4j2. In particular, I want to use the apache flume appender. (http://logging.apache.org/log4j/2.x/log4j-flume-ng/)

When I build, I wind up with the Log4j2Plugins.dat from log4j, which doesn't have support for the flume appender, so I can't register the flume appender in my log4j2.xml. It seems that there's no way to register custom appender classes just via log4j2.xml, and instead I have to use PluginManager to register the \org\apache\logging\log4j\core\config\plugins\Log4j2Plugin.dat. I can't find any examples of how to do this, let alone examples of how to automate this in a build.

Is it possible to register a custom appender class solely through log4j2.xml, or do I need to go through the PluginManager? Whatever the answer, can someone show me an example? I'm particularly interested in how to automate this in a build.


Thanks,
Roman



RE: configuring a non-core appender in log4j2

Posted by "Zabicki Roman (HERE/Chicago)" <ro...@here.com>.
That did the trick. Thank you for your help.

-----Original Message-----
From: Zabicki Roman (HERE/Chicago) 
Sent: Friday, March 21, 2014 5:25 PM
To: Log4J Users List
Subject: RE: configuring a non-core appender in log4j2

"when I build" -- you've described the problem exactly. I'm building with maven, and we combine all of our classes and all the classes from the jars we're dependent on into one single jar. This single jar can, of course, only have 1 Log4j2Plugin.dat. I have to stick with this build/deployment strategy. I can't deploy multiple jars. So I will use the packages attribute and let you know on Monday how it goes. Thanks for pointing that out. I had read that page before, but I didn't get it.



-----Original Message-----
From: Ralph Goers [mailto:ralph.goers@dslextreme.com] 
Sent: Friday, March 21, 2014 3:56 PM
To: Log4J Users List
Subject: Re: configuring a non-core appender in log4j2

If the log4j flume jar is in the class path it should automatically be included as it has its own Log4j2Plugin.dat file.   However, you can always manually cause plugins to be located by specifying the packages attribute - see http://logging.apache.org/log4j/2.x/manual/configuration.html#XML.

Again though, if it is not automatically finding the Flume Appender then there is either something wrong in your configuration or the log4j-flume-ng jar is not in the classpath.

I'm curious though - when you say "when I build" what exactly are you building?  You cannot build a new jar that includes the contents of log4j-core.jar and the contents of other jars that also have plugins as each has their own Log4j2Plugin.dat and only one of them will wind up in your new jar.  To do that, yes you would have to run the PluginManager against the contents of your new jar to generate your own custom Log4j2Plugin.dat.  However, doing that is not recommended.  We recommend that you leave the Log4j jars alone and include them in your classpath.

Ralph

On Mar 21, 2014, at 12:30 PM, Zabicki Roman (HERE/Chicago) <ro...@here.com> wrote:

> Hi,
> 
> I want to use a non-core appender with log4j2. In particular, I want to use the apache flume appender. (http://logging.apache.org/log4j/2.x/log4j-flume-ng/)
> 
> When I build, I wind up with the Log4j2Plugins.dat from log4j, which doesn't have support for the flume appender, so I can't register the flume appender in my log4j2.xml. It seems that there's no way to register custom appender classes just via log4j2.xml, and instead I have to use PluginManager to register the \org\apache\logging\log4j\core\config\plugins\Log4j2Plugin.dat. I can't find any examples of how to do this, let alone examples of how to automate this in a build.
> 
> Is it possible to register a custom appender class solely through log4j2.xml, or do I need to go through the PluginManager? Whatever the answer, can someone show me an example? I'm particularly interested in how to automate this in a build.
> 
> 
> Thanks,
> Roman
> 
> 


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


Re: configuring a non-core appender in log4j2

Posted by Ralph Goers <rg...@apache.org>.
Just as an FYI if you have multiple packages your start up time is going to be impacted.  Getting the plugins from the file is orders of magnitude faster than dynamically locating them at runtime.

I'd love to hear why it was necessary to build a single jar. Hardly anyone recommends doing that, especially when using Maven.

Ralph

> On Mar 21, 2014, at 3:25 PM, "Zabicki Roman (HERE/Chicago)" <ro...@here.com> wrote:
> 
> "when I build" -- you've described the problem exactly. I'm building with maven, and we combine all of our classes and all the classes from the jars we're dependent on into one single jar. This single jar can, of course, only have 1 Log4j2Plugin.dat. I have to stick with this build/deployment strategy. I can't deploy multiple jars. So I will use the packages attribute and let you know on Monday how it goes. Thanks for pointing that out. I had read that page before, but I didn't get it.
> 
> 
> 
> -----Original Message-----
> From: Ralph Goers [mailto:ralph.goers@dslextreme.com] 
> Sent: Friday, March 21, 2014 3:56 PM
> To: Log4J Users List
> Subject: Re: configuring a non-core appender in log4j2
> 
> If the log4j flume jar is in the class path it should automatically be included as it has its own Log4j2Plugin.dat file.   However, you can always manually cause plugins to be located by specifying the packages attribute - see http://logging.apache.org/log4j/2.x/manual/configuration.html#XML.
> 
> Again though, if it is not automatically finding the Flume Appender then there is either something wrong in your configuration or the log4j-flume-ng jar is not in the classpath.
> 
> I'm curious though - when you say "when I build" what exactly are you building?  You cannot build a new jar that includes the contents of log4j-core.jar and the contents of other jars that also have plugins as each has their own Log4j2Plugin.dat and only one of them will wind up in your new jar.  To do that, yes you would have to run the PluginManager against the contents of your new jar to generate your own custom Log4j2Plugin.dat.  However, doing that is not recommended.  We recommend that you leave the Log4j jars alone and include them in your classpath.
> 
> Ralph
> 
>> On Mar 21, 2014, at 12:30 PM, Zabicki Roman (HERE/Chicago) <ro...@here.com> wrote:
>> 
>> Hi,
>> 
>> I want to use a non-core appender with log4j2. In particular, I want to use the apache flume appender. (http://logging.apache.org/log4j/2.x/log4j-flume-ng/)
>> 
>> When I build, I wind up with the Log4j2Plugins.dat from log4j, which doesn't have support for the flume appender, so I can't register the flume appender in my log4j2.xml. It seems that there's no way to register custom appender classes just via log4j2.xml, and instead I have to use PluginManager to register the \org\apache\logging\log4j\core\config\plugins\Log4j2Plugin.dat. I can't find any examples of how to do this, let alone examples of how to automate this in a build.
>> 
>> Is it possible to register a custom appender class solely through log4j2.xml, or do I need to go through the PluginManager? Whatever the answer, can someone show me an example? I'm particularly interested in how to automate this in a build.
>> 
>> 
>> Thanks,
>> Roman
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 

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


RE: configuring a non-core appender in log4j2

Posted by "Zabicki Roman (HERE/Chicago)" <ro...@here.com>.
"when I build" -- you've described the problem exactly. I'm building with maven, and we combine all of our classes and all the classes from the jars we're dependent on into one single jar. This single jar can, of course, only have 1 Log4j2Plugin.dat. I have to stick with this build/deployment strategy. I can't deploy multiple jars. So I will use the packages attribute and let you know on Monday how it goes. Thanks for pointing that out. I had read that page before, but I didn't get it.



-----Original Message-----
From: Ralph Goers [mailto:ralph.goers@dslextreme.com] 
Sent: Friday, March 21, 2014 3:56 PM
To: Log4J Users List
Subject: Re: configuring a non-core appender in log4j2

If the log4j flume jar is in the class path it should automatically be included as it has its own Log4j2Plugin.dat file.   However, you can always manually cause plugins to be located by specifying the packages attribute - see http://logging.apache.org/log4j/2.x/manual/configuration.html#XML.

Again though, if it is not automatically finding the Flume Appender then there is either something wrong in your configuration or the log4j-flume-ng jar is not in the classpath.

I'm curious though - when you say "when I build" what exactly are you building?  You cannot build a new jar that includes the contents of log4j-core.jar and the contents of other jars that also have plugins as each has their own Log4j2Plugin.dat and only one of them will wind up in your new jar.  To do that, yes you would have to run the PluginManager against the contents of your new jar to generate your own custom Log4j2Plugin.dat.  However, doing that is not recommended.  We recommend that you leave the Log4j jars alone and include them in your classpath.

Ralph

On Mar 21, 2014, at 12:30 PM, Zabicki Roman (HERE/Chicago) <ro...@here.com> wrote:

> Hi,
> 
> I want to use a non-core appender with log4j2. In particular, I want to use the apache flume appender. (http://logging.apache.org/log4j/2.x/log4j-flume-ng/)
> 
> When I build, I wind up with the Log4j2Plugins.dat from log4j, which doesn't have support for the flume appender, so I can't register the flume appender in my log4j2.xml. It seems that there's no way to register custom appender classes just via log4j2.xml, and instead I have to use PluginManager to register the \org\apache\logging\log4j\core\config\plugins\Log4j2Plugin.dat. I can't find any examples of how to do this, let alone examples of how to automate this in a build.
> 
> Is it possible to register a custom appender class solely through log4j2.xml, or do I need to go through the PluginManager? Whatever the answer, can someone show me an example? I'm particularly interested in how to automate this in a build.
> 
> 
> Thanks,
> Roman
> 
> 


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


Re: configuring a non-core appender in log4j2

Posted by Ralph Goers <ra...@dslextreme.com>.
If the log4j flume jar is in the class path it should automatically be included as it has its own Log4j2Plugin.dat file.   However, you can always manually cause plugins to be located by specifying the packages attribute - see http://logging.apache.org/log4j/2.x/manual/configuration.html#XML.

Again though, if it is not automatically finding the Flume Appender then there is either something wrong in your configuration or the log4j-flume-ng jar is not in the classpath.

I’m curious though - when you say “when I build” what exactly are you building?  You cannot build a new jar that includes the contents of log4j-core.jar and the contents of other jars that also have plugins as each has their own Log4j2Plugin.dat and only one of them will wind up in your new jar.  To do that, yes you would have to run the PluginManager against the contents of your new jar to generate your own custom Log4j2Plugin.dat.  However, doing that is not recommended.  We recommend that you leave the Log4j jars alone and include them in your classpath.

Ralph

On Mar 21, 2014, at 12:30 PM, Zabicki Roman (HERE/Chicago) <ro...@here.com> wrote:

> Hi,
> 
> I want to use a non-core appender with log4j2. In particular, I want to use the apache flume appender. (http://logging.apache.org/log4j/2.x/log4j-flume-ng/)
> 
> When I build, I wind up with the Log4j2Plugins.dat from log4j, which doesn't have support for the flume appender, so I can't register the flume appender in my log4j2.xml. It seems that there's no way to register custom appender classes just via log4j2.xml, and instead I have to use PluginManager to register the \org\apache\logging\log4j\core\config\plugins\Log4j2Plugin.dat. I can't find any examples of how to do this, let alone examples of how to automate this in a build.
> 
> Is it possible to register a custom appender class solely through log4j2.xml, or do I need to go through the PluginManager? Whatever the answer, can someone show me an example? I'm particularly interested in how to automate this in a build.
> 
> 
> Thanks,
> Roman
> 
>