logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian Becker (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4NET-458) LocalSyslogAppender does not support multiple identities
Date Mon, 11 May 2015 14:38:01 GMT

    [ https://issues.apache.org/jira/browse/LOG4NET-458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14537989#comment-14537989
] 

Christian Becker commented on LOG4NET-458:
------------------------------------------

Hi Stefan,

thank you for the patch.

We've implemented it on May 30th and there are no issues so far.

Cheers,
Christian

> LocalSyslogAppender does not support multiple identities
> --------------------------------------------------------
>
>                 Key: LOG4NET-458
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-458
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.13
>            Reporter: Christian Becker
>         Attachments: localsyslog.patch
>
>
> With multiple LocalSyslogAppender where each one has a different identity, everything
just gets logged with the identity of the last Appender.
> In the example below, every log message has the identity of task_info_syslog, even the
appender used is rts_syslog.
> I checked the code and this is a bug in LocalSyslogAppender.Append(). 
> The syslogtag is not part of the syslog() function call, but has to be done using openlog()
and after a call to openlog(), the identity set is used for all subsequent syslog() calls.
> A call to openlog() is only done once in ActivateOptions() and never again, this causes
the observed behavior, that the last instance of LocalSyslogAppender wins. 
> A possible fix for this is to add a call to openlog() in Append() before calling syslog(),
like:
> {code}
> diff --git a/LocalSyslogAppender.cs b/LocalSyslogAppender.cs
> --- a/LocalSyslogAppender.cs
> +++ b/LocalSyslogAppender.cs
> @@ -387,6 +387,8 @@ namespace log4net.Appender
>              int priority = GeneratePriority(m_facility, GetSeverity(loggingEvent.Level));
>              string message = RenderLoggingEvent(loggingEvent);
> +            // Call libc openlog() first to ensure correct identity and facility is
set
> +            openlog(m_handleToIdentity, 1, m_facility);
>              // Call the local libc syslog method
>              // The second argument is a printf style format string
>              syslog(priority, "%s", message);
> {code}
> Here is our config for reference:
> {code}
> [...]
> <appender name="rts_syslog" type="log4net.Appender.LocalSyslogAppender">
>   <facility value="User" />
>   <identity type="log4net.Util.PatternString" value="foobar/dev/dev1/rts" />
>   <layout type="log4net.Layout.PatternLayout">
>     <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss}, %level, %message%newline"
/>
>   </layout>
> </appender>
> [...]
> <appender name="task_info_syslog" type="log4net.Appender.LocalSyslogAppender">
>   <facility value="User" />
>   <identity type="log4net.Util.PatternString" value="foobar/dev/dev1/task-info" />
>   <layout type="log4net.Layout.PatternLayout">
>     <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss}, %level, %message%newline"
/>
>   </layout>
> </appender>
> [...]
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message