Hi JB,

After adoption one of log4j2 GELF appenders I’ve share results with example 
configuration. Installation process of custom appender in general already 
properly documented in section «Custom appenders» of User Guide. 

Configuration example for gelfj appender for current Karaf (log4j 1.x) releases:

1. Install bundle in any way:

mvn:org.graylog2/gelfj/1.1.14

2. Modify config file org.ops4j.pax.logging.cfg by adding section:

# Async wrapper for send queue in case of GELF destination is unavailable
log4j.appender.gelfasync=org.apache.log4j.AsyncAppender
log4j.appender.gelfasync.blocking=false
log4j.appender.gelfasync.bufferSize=20000
log4j.appender.gelfasync.appenders=gelf

# Define the GELF destination
log4j.appender.gelf=org.graylog2.log.GelfAppender
log4j.appender.gelf.graylogHost=tcp:<gelf_receiver_host>
log4j.appender.gelf.graylogPort=<gelf_receiver_port>
log4j.appender.gelf.facility=karaf
log4j.appender.gelf.layout=org.apache.log4j.PatternLayout
log4j.appender.gelf.extractStacktrace=true
log4j.appender.gelf.addExtendedInformation=true
log4j.appender.gelf.includeLocation=false
log4j.appender.gelf.additionalFields={'environment': 'QA'}

3. Modify config file org.ops4j.pax.logging.cfg by adding appender ‘gelfasync’ 
to global appenders list. Example:

log4j.rootLogger=INFO, out, osgi:*, gelfasync


Regards,
Vladimir Konkov
CIT Consulting LLC

> 20 марта 2016 г., в 10:56, Jean-Baptiste Onofré <j...@nanthrax.net> 
> написал(а):
> 
> Hi Valdimir,
> 
> by feature, I meant "a simple way" to provide/add it (not necessary a Karaf 
> feature) ;)
> 
> Probably the easier way now is to document how to do it in the dev guide with 
> an associated sample.
> 
> Regards
> JB
> 
> On 03/19/2016 03:03 PM, Владимир Коньков wrote:
>> Hi Jean-Baptiste!
>> 
>> We actively use GELF for streaming logs from Karaf based platforms for
>> years. But we stop building custom distributions at beginning of
>> adoption because of we use use different distrs from different vendors
>> (FuseSource, Talend, stock Servicemix, plain Karaf etc). Not all distrs
>> can be modified. It all needs to be upgradable.
>> Custom distribution is not practical way for us. Now we install appender
>> at deployment time by help of deployment automation tools like Ansible,
>> Puppet.
>> 
>> Current appender we use is GELFJ. Not so robust as I want but with some
>> infrastructure support it works:
>> 
>> https://github.com/t0xa/gelfj
>> 
>> It is already has OSGI headers to be fragment bundle for Pax-Logging.
>> 
>> For log4j2 I currently testing this 2 implementations:
>> 
>> 1. https://github.com/Graylog2/log4j2-gelf
>> 
>> 2. https://github.com/mp911de/logstash-gelf
>> 
>> For fist I’ve made couple of changes + OSGI headers for both. If someone
>> is interested in I can share results after decision to be made with
>> small configuration example. As before, we not plan build custom distrs.
>> 
>> I think Karaf feature is not to be needed because there is only one
>> proper way to package appender - one superbundle, fragment for
>> Pax-Logging without any exports and imports. Because of that -
>> installation of appender it is simple bundle installation and Karaf
>> restart. Or startup.properties modification, etc…
>> 
>> Regards,
>> Vladimir Konkov
>> CIT Consulting LLC
>> 
>>> 17 марта 2016 г., в 22:17, Jean-Baptiste Onofré <j...@nanthrax.net
>>> <mailto:j...@nanthrax.net <mailto:j...@nanthrax.net>>> написал(а):
>>> 
>>> Hi Vladimir
>>> 
>>> anyway, do you already have GELF in your custom distribution ?
>>> If so, I would love to document it for other potential users, or even
>>> propose an optional feature to add this.
>>> 
>>> WDYT ?
>>> 
>>> Regards
>>> JB
>>> 
>>> On 03/17/2016 06:33 AM, Владимир Коньков wrote:
>>>> Hi there!
>>>> 
>>>> Lukasz, Jean-Baptiste, thanx for reply. Actually your opinion is
>>>> expected and reasonable.
>>>> 
>>>> Lukasz, couple of comments:
>>>> 
>>>> Proposed solution is not specific for any tool - GELF is very common
>>>> format for app log streaming and it’s popularity is growing.
>>>> 
>>>> About custom distribution:
>>>> Usually, ops team is orthogonal to dev team. Infrastructure services
>>>> like logging provided by ops team, deployment platform stated by dev
>>>> team. It’s not comfortable to require custom version of Karaf from
>>>> dev team. Moreover it is not always possible. In our projects we
>>>> support many Karaf versions and distribution from Apache Servicemix
>>>> 4.4 (Karaf 2.2.x) to TalendESB 5.x to modern Karaf 4.0.x - it is far
>>>> from always possible to build custom distr. But on all of this distrs
>>>> we use one set of custom appenders (!) for 4+ years. One of that
>>>> appenders finally die (compression, file rotation etc), but not other.
>>>> 
>>>> Lukasz is absolutely right - logging is part of foundation
>>>> functionalities and because of that it is hard to extend in
>>>> comparison to other parts. I’ve first voted for removing blueprint
>>>> from base distribution but ask you for common streaming log appender.
>>>> 
>>>> Anyway, thanx for Karaf - it is very good platform for any server
>>>> solutions on JVM. Of cause if you want and can adapt it.
>>>> 
>>>> Regards,
>>>> Vladimir Konkov
>>>> 
>>> 
>>> --
>>> Jean-Baptiste Onofré
>>> jbono...@apache.org <mailto:jbono...@apache.org> 
>>> <mailto:jbono...@apache.org <mailto:jbono...@apache.org>>
>>> http://blog.nanthrax.net <http://blog.nanthrax.net/>
>>> Talend - http://www.talend.com <http://www.talend.com/>
>> 
> 
> -- 
> Jean-Baptiste Onofré
> jbono...@apache.org <mailto:jbono...@apache.org>
> http://blog.nanthrax.net <http://blog.nanthrax.net/>
> Talend - http://www.talend.com <http://www.talend.com/>

Reply via email to