You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2016/07/23 17:58:20 UTC

[jira] [Comment Edited] (LOG4J2-949) No MDC parameters in Syslog

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

Gary Gregory edited comment on LOG4J2-949 at 7/23/16 5:57 PM:
--------------------------------------------------------------

I face the same issue. I ensure variables are set: org.slf4j.MDC.put("thread", "threadidvalue")

But, the values are not printed in syslog:

xml:
{code:xml}
<Syslog name="SyslogAppender" format="RFC5424" host="10.21.24.242" port="514"
            protocol="UDP" appName="MyApp" includeMDC="true"
            facility="LOCAL0" enterpriseNumber="18060" newLine="true"
            messageId="Audit" id="App" mdcId="mdc">
        <param name="loggerFields">
            <LoggerFields>
                <KeyValuePair key="thread" value="%t"/>
            </LoggerFields>  
        </param>
        </Syslog>
{code}



was (Author: kanagha):
I face the same issue. I ensure variables are set: org.slf4j.MDC.put("thread", "threadidvalue")

But, the values are not printed in syslog:

xml:

<Syslog name="SyslogAppender" format="RFC5424" host="10.21.24.242" port="514"
            protocol="UDP" appName="MyApp" includeMDC="true"
            facility="LOCAL0" enterpriseNumber="18060" newLine="true"
            messageId="Audit" id="App" mdcId="mdc">
        <param name="loggerFields">
            <LoggerFields>
                <KeyValuePair key="thread" value="%t"/>
            </LoggerFields>  
        </param>
        </Syslog>



> No MDC parameters in Syslog
> ---------------------------
>
>                 Key: LOG4J2-949
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-949
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.1
>         Environment: Ubuntu 12
>            Reporter: Maxim Novikov
>            Priority: Critical
>              Labels: mdc, syslog, syslogappender, threadcontext
>
> I cannot see thread context specific parameters (MDC) with the Syslog appender.
> Here is my configuration:
> {code:title=log4j2.xml|borderStyle=solid}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="WARN">
>   <Appenders>
>     <Console name="Console" target="SYSTEM_OUT">
>       <PatternLayout pattern="%X{my-mdc-key} %d{HH:mm:ss.SSS} %-5level [%logger{1.}] %msg%n" />
>     </Console>
>     <Syslog name="Syslog"
>             format="RFC5424"
>             host="localhost"
>             port="514"
>             protocol="UDP" 
>             id="my-id"
>             mdcId="mdc"
>             mdcRequired="my-mdc-key"
>             enterpriseNumber="1000"
>             newLine="true"
>             appName="my-app">
>       <LoggerFields>
>         <KeyValuePair key="thread" value="%t" />
>         <KeyValuePair key="category" value="%c" />
>       </LoggerFields>
>     </Syslog>
>   </Appenders>
>   <Loggers>
>     <Root level="info">
>       <AppenderRef ref="Console" />
>       <AppenderRef ref="Syslog" />
>     </Root>
> </Configuration>
> {code}
> I can see my-mdc-key's value in the terminal just fine (as well as other MDC custom parameters if I need to), but there is none is syslog's log file.
> The same concerns the LoggerFields collection. I have added it just to try overcoming the issue with MDC, but also can't see any of those through syslog.
> I have tried to play with "mdcId", "mdcRequired", "mdcRequired", but with no success. The only thing for sure is that my MDC custom fields do exist in the context, as I can see them in the console, as well as Syslog appender starts with not exception when I specify them through "mdcRequired" field.
> PS Just to clarify, the messages do get delivered to the syslog, but no MDC and no custom logger fields there.
> Marked as "Critical" as we will have to migrate to logback or another framework if it is not going to work, as this functionality is required for us.



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

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