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 Reilly Brogan <re...@procentive.com> on 2018/10/11 23:52:21 UTC

GelfLayout with Newlines?

Hello all, I've been working on a project to replace the Tomcat server
logging (catalina + access) with structured logging via log4j2. These logs
need to be written to desk (a mounted NFS share) where they will be
processed by another collector to be sent to multiple destinations.

I've experimented with a few different layouts and the one that includes
all of the data I need without any extraneous fields that can't be excluded
(JsonLayout...) is GelfLayout. My issue with this one is there is no option
to add a newline or separating character between each log event when
logging to console or a file. I've taken a look at the specification of the
format and it doesn't seem to prohibit this at all (it actually doesn't
cover any case where you're not sending the format over TCP or UDP) and
this is a requirement for our log parser (fluentd) as it uses newlines to
determine when new events have been written to the log files.

Is there anything I'm missing here that would allow me to manually add
newlines so that I can get this working? Perhaps the ability to pass the
results of GelfLayout into a PatternLayout where I can manually add the
newline or some parameter of the console or file appenders that forces the
character be added that I'm not seeing? I would prefer to avoid having to
write my own format using PatternLayout or have to use parsing to drop the
extraneous keys from JsonLayout (and using up extra disk space in the
process).

Thanks for any assistance,
Reilly
-- 
Reilly Brogan
System Engineer
Tevera
1-(715)-245-8044
Reilly@procentive.com