[logback-user] syslogappender stacktraces get cut

Ingebrigt Berg ingebrigt at jpro.no
Tue Mar 20 12:02:39 CET 2012


Hi !

We've recently made the switch from Log4j to Logback. We use Syslog to send
logfiles to our logserver, and things generally work.

But when there are stacktraces in the logs we get in trouble.
SyslogAppender will replace lineshifts with '#011' to make the logentry a
single line. Then it will cut each line that is to long according to the
syslog limit of 2K/line. Only the fist segment will arrive in the correct
log. The remaining segments do not contain everything in the suffixPattern,
and our regexp will not have anything to match. The segment will end up in
a 'trash' log for unmatchable loglines.

My config for the SyslogAppender looks like this:

    <contextName>company-${CONTEXT_PATH}-${environment}</contextName>
    <appender name="LOGSERVER_FILE"
class="ch.qos.logback.classic.net.SyslogAppender">
        <syslogHost>localhost</syslogHost>
        <facility>local3</facility>
        <SuffixPattern>%contextName %d{dd.MM.yyyy HH:mm:ss.SSS} [%p]
[%c{1}] [%X{ThreadId}]: %m%n</SuffixPattern>
    </appender>

We use the contextName property to control the logfilename. On the
receiving end we read the contextName parameter (using a regexp) for each
log line, and write the line to a file with a corresponding name.

We had a similar problem when we used Log4J (Where the Tag element was used
in the same manner), and fixed it back then by writing a custom log4j
SyslogAppender. But the main purpose of moving to Logback is to loose all
our home brew logging stuff, we don't want to go down that path again. If
we can't make Logback work out of the box with Syslog we'll probably end up
going back to Log4J. (Another alternative is to replace Syslog with Gelf,
but that's further down the road).

However, I imagine Logback and Syslog being a common combination, and
surely someone must have this working out of the box. Any advice will be
appreciated. My requirements are simple:
-must work with no custom logging code, only config (preferably xml)
-stacktraces in logs must work
-must be able to fully control the filename on the recieving end.

cheers,
Ingebrigt Berg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120320/b726feee/attachment.html>


More information about the Logback-user mailing list