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 Priya Ahuja <pr...@gmail.com> on 2015/08/04 21:30:13 UTC

Structured data appearing twice

Hi,

I am trying to add structured data using includeMDC and loggerfields but I
also want MESSAGE-ID passed by the user in the log.

*My current implementation:*
I am passing StructuredDataMessage to logIfEnabled since that is the only
way to pass user defined message-id
       - StructuredDataMessage((String)null, msg, messageId)

But I want the structured data picked up from* XML configuration:*

        <Syslog name="RFC5424" format="RFC5424" enterpriseNumber=6876
               * id="LS" includeMDC="true" mdcId="enterprise"*
                mdcIncludes="comp,subcomp">
                <LoggerFields>
                    <KeyValuePair key="level" value="dummy" />
                    <KeyValuePair key="id" value="dummy" />
                </LoggerFields>

As a result my structured data appears twice in the log:
<182>1 2015-08-03T20:28:16.413Z localhost - - USER *[enterprise@6876
level="dummy" id="dummy"][@6876] *This is a dummy log

Any help appreciated.

Thanks,
Priya Ahuja

Re: Structured data appearing twice

Posted by Gary Gregory <ga...@gmail.com>.
Hi Priya,

I would start by updating to 2.3 and then test again. If not fixed look, in
changes.xml [1] in Git master to see if this has been fixed in the upcoming
2.4 release:

Gary

[1]
https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;a=blob_plain;f=src/changes/changes.xml;hb=HEAD

On Tue, Aug 4, 2015 at 1:41 PM, Priya Ahuja <pr...@gmail.com> wrote:

> Hi Gary,
>
> I am currently using version 2.1.
>
> I have attached the log4j configuration file.
>
> Thanks,
> Priya Ahuja
>
>
>
> On Tue, Aug 4, 2015 at 12:36 PM, Gary Gregory <ga...@gmail.com>
> wrote:
>
>> Hi Priya,
>>
>> What is your configuration? What version are you using?
>>
>> Gary
>>
>> On Tue, Aug 4, 2015 at 12:30 PM, Priya Ahuja <pr...@gmail.com>
>> wrote:
>>
>> > Hi,
>> >
>> > I am trying to add structured data using includeMDC and loggerfields
>> but I
>> > also want MESSAGE-ID passed by the user in the log.
>> >
>> > *My current implementation:*
>> > I am passing StructuredDataMessage to logIfEnabled since that is the
>> only
>> > way to pass user defined message-id
>> >        - StructuredDataMessage((String)null, msg, messageId)
>> >
>> > But I want the structured data picked up from* XML configuration:*
>> >
>> >         <Syslog name="RFC5424" format="RFC5424" enterpriseNumber=6876
>> >                * id="LS" includeMDC="true" mdcId="enterprise"*
>> >                 mdcIncludes="comp,subcomp">
>> >                 <LoggerFields>
>> >                     <KeyValuePair key="level" value="dummy" />
>> >                     <KeyValuePair key="id" value="dummy" />
>> >                 </LoggerFields>
>> >
>> > As a result my structured data appears twice in the log:
>> > <182>1 2015-08-03T20:28:16.413Z localhost - - USER *[enterprise@6876
>> > level="dummy" id="dummy"][@6876] *This is a dummy log
>> >
>> > Any help appreciated.
>> >
>> > Thanks,
>> > Priya Ahuja
>> >
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Structured data appearing twice

Posted by Priya Ahuja <pr...@gmail.com>.
my syslog configuration is:

        <Syslog name="RFC5424" format="RFC5424"
                messageId="" id="" includeMDC="true" mdcId="nsx"
mdcIncludes="comp,subcomp">
            <LoggerFields>
                <KeyValuePair key="comp" value="manager" />
                <KeyValuePair key="subcomp" value="web" />
            </LoggerFields>
        </Syslog>

On Tue, Sep 15, 2015 at 2:12 PM, Priya Ahuja <pr...@gmail.com> wrote:

> I have a common logging library integrated with log4j which is being used
> by different packages/classes. I want a custom messageid in the log entry
> so that filtering is easy. At the same time I want structured data fields
> to be a part of configuration. For ex:
>
> *<180>1 2015-02-12T00:04:57:627Z 10.1.1.2 - - HTTP [ id@68146
> comp="manager” subcomp=“web" ] Received an HTTP request.*
>
> * <180>1 2015-02-12T00:04:57:627Z 10.1.1.2 - - RPC [ id@68146
> comp="manager” subcomp=“web"] Received an RPC request.*
>
> The messageid will be passed as part of logger constructor based on the
> log message content (logger constructor modified to do so) but the
> structured data fields are common that can be provided in the configuration
> using MDC but it doesn't work since I need messageid to be custom I am
> forced to use StructuredDataMessage (see below). Currently I am passing the
> structured data fields and the messageid as part of the message itself, see
> code below:
>
>   private Message format(final String pattern, final Object... arguments) {
>         String msg = arguments != null ?
> Utils.formatAsLogSFPattern(pattern, arguments) : pattern;
>         Map<String, String> m = new HashMap<String, String>();
>         m.put("comp", *this.comp*);       *//messageid, comp and subcomp
> is received as part of logger constructor*
>         m.put("subcomp",* this.subcomp*);
>         return new *StructuredDataMessage*("nsx", msg,* this.messageId, m*
> );
>     }
>
>     public void fatal(String format, Object... args) {
>         if (log4jLogger.isEnabled(Level.FATAL)) {
>             log4jLogger.logIfEnabled(FQCN, Level.FATAL, null,
> format(format, args), null);
>         }
>     }
>
> If I remove the map implementation and pass NULL then I get 2 structured
> data fields in the log.
>
>
> On Tue, Sep 15, 2015 at 1:00 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>
>> Can you describe your use case in a bit more detail?  Maybe we can
>> provide some other ideas on how to resolve it.
>>
>> Ralph
>>
>> > On Sep 15, 2015, at 12:17 PM, Priya Ahuja <pr...@gmail.com>
>> wrote:
>> >
>> > Thanks Gary! I will update after trying with 2.3. I have a mild idea on
>> > what may be going wrong. My requirement is that I need userdefined id
>> > (messageid) and configuration based structured data.
>> >
>> > 1. Messageid is only parsed in log4j if the message is an instance of
>> > StructuredDataMessage, hence I am forced to send my message to log4j as
>> > structuredDataMessage with empty Map for structured data
>> > 2. As a result, the final message gets parsed indexed with two maps,
>> once
>> > from the config file and other from the message itself
>> >
>> > Thanks,
>> > Priya Ahuja
>> >
>> > On Mon, Sep 14, 2015 at 7:57 PM, Gary Gregory <ga...@gmail.com>
>> > wrote:
>> >
>> >> Can you try version 2.3 or 2.4 out of Git master?
>> >>
>> >> Gary
>> >>
>> >> On Tue, Aug 4, 2015 at 1:41 PM, Priya Ahuja <pr...@gmail.com>
>> wrote:
>> >>
>> >>> Hi Gary,
>> >>>
>> >>> I am currently using version 2.1.
>> >>>
>> >>> I have attached the log4j configuration file.
>> >>>
>> >>> Thanks,
>> >>> Priya Ahuja
>> >>>
>> >>>
>> >>>
>> >>> On Tue, Aug 4, 2015 at 12:36 PM, Gary Gregory <garydgregory@gmail.com
>> >
>> >>> wrote:
>> >>>
>> >>>> Hi Priya,
>> >>>>
>> >>>> What is your configuration? What version are you using?
>> >>>>
>> >>>> Gary
>> >>>>
>> >>>> On Tue, Aug 4, 2015 at 12:30 PM, Priya Ahuja <pr...@gmail.com>
>> >>>> wrote:
>> >>>>
>> >>>>> Hi,
>> >>>>>
>> >>>>> I am trying to add structured data using includeMDC and loggerfields
>> >>>> but I
>> >>>>> also want MESSAGE-ID passed by the user in the log.
>> >>>>>
>> >>>>> *My current implementation:*
>> >>>>> I am passing StructuredDataMessage to logIfEnabled since that is the
>> >>>> only
>> >>>>> way to pass user defined message-id
>> >>>>>       - StructuredDataMessage((String)null, msg, messageId)
>> >>>>>
>> >>>>> But I want the structured data picked up from* XML configuration:*
>> >>>>>
>> >>>>>        <Syslog name="RFC5424" format="RFC5424" enterpriseNumber=6876
>> >>>>>               * id="LS" includeMDC="true" mdcId="enterprise"*
>> >>>>>                mdcIncludes="comp,subcomp">
>> >>>>>                <LoggerFields>
>> >>>>>                    <KeyValuePair key="level" value="dummy" />
>> >>>>>                    <KeyValuePair key="id" value="dummy" />
>> >>>>>                </LoggerFields>
>> >>>>>
>> >>>>> As a result my structured data appears twice in the log:
>> >>>>> <182>1 2015-08-03T20:28:16.413Z localhost - - USER *[enterprise@6876
>> >>>>> level="dummy" id="dummy"][@6876] *This is a dummy log
>> >>>>>
>> >>>>> Any help appreciated.
>> >>>>>
>> >>>>> Thanks,
>> >>>>> Priya Ahuja
>> >>>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>> --
>> >>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> >>>> Java Persistence with Hibernate, Second Edition
>> >>>> <http://www.manning.com/bauer3/>
>> >>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> >>>> Spring Batch in Action <http://www.manning.com/templier/>
>> >>>> Blog: http://garygregory.wordpress.com
>> >>>> Home: http://garygregory.com/
>> >>>> Tweet! http://twitter.com/GaryGregory
>> >>>>
>> >>>
>> >>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> >>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> >> Java Persistence with Hibernate, Second Edition
>> >> <http://www.manning.com/bauer3/>
>> >> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> >> Spring Batch in Action <http://www.manning.com/templier/>
>> >> Blog: http://garygregory.wordpress.com
>> >> Home: http://garygregory.com/
>> >> Tweet! http://twitter.com/GaryGregory
>> >>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>
>>
>

Re: Structured data appearing twice

Posted by Priya Ahuja <pr...@gmail.com>.
I have a common logging library integrated with log4j which is being used
by different packages/classes. I want a custom messageid in the log entry
so that filtering is easy. At the same time I want structured data fields
to be a part of configuration. For ex:

*<180>1 2015-02-12T00:04:57:627Z 10.1.1.2 - - HTTP [ id@68146
comp="manager” subcomp=“web" ] Received an HTTP request.*

* <180>1 2015-02-12T00:04:57:627Z 10.1.1.2 - - RPC [ id@68146
comp="manager” subcomp=“web"] Received an RPC request.*

The messageid will be passed as part of logger constructor based on the log
message content (logger constructor modified to do so) but the structured
data fields are common that can be provided in the configuration using MDC
but it doesn't work since I need messageid to be custom I am forced to use
StructuredDataMessage (see below). Currently I am passing the structured
data fields and the messageid as part of the message itself, see code below:

  private Message format(final String pattern, final Object... arguments) {
        String msg = arguments != null ?
Utils.formatAsLogSFPattern(pattern, arguments) : pattern;
        Map<String, String> m = new HashMap<String, String>();
        m.put("comp", *this.comp*);       *//messageid, comp and subcomp is
received as part of logger constructor*
        m.put("subcomp",* this.subcomp*);
        return new *StructuredDataMessage*("nsx", msg,* this.messageId, m*);
    }

    public void fatal(String format, Object... args) {
        if (log4jLogger.isEnabled(Level.FATAL)) {
            log4jLogger.logIfEnabled(FQCN, Level.FATAL, null,
format(format, args), null);
        }
    }

If I remove the map implementation and pass NULL then I get 2 structured
data fields in the log.


On Tue, Sep 15, 2015 at 1:00 PM, Ralph Goers <ra...@dslextreme.com>
wrote:

> Can you describe your use case in a bit more detail?  Maybe we can provide
> some other ideas on how to resolve it.
>
> Ralph
>
> > On Sep 15, 2015, at 12:17 PM, Priya Ahuja <pr...@gmail.com> wrote:
> >
> > Thanks Gary! I will update after trying with 2.3. I have a mild idea on
> > what may be going wrong. My requirement is that I need userdefined id
> > (messageid) and configuration based structured data.
> >
> > 1. Messageid is only parsed in log4j if the message is an instance of
> > StructuredDataMessage, hence I am forced to send my message to log4j as
> > structuredDataMessage with empty Map for structured data
> > 2. As a result, the final message gets parsed indexed with two maps, once
> > from the config file and other from the message itself
> >
> > Thanks,
> > Priya Ahuja
> >
> > On Mon, Sep 14, 2015 at 7:57 PM, Gary Gregory <ga...@gmail.com>
> > wrote:
> >
> >> Can you try version 2.3 or 2.4 out of Git master?
> >>
> >> Gary
> >>
> >> On Tue, Aug 4, 2015 at 1:41 PM, Priya Ahuja <pr...@gmail.com>
> wrote:
> >>
> >>> Hi Gary,
> >>>
> >>> I am currently using version 2.1.
> >>>
> >>> I have attached the log4j configuration file.
> >>>
> >>> Thanks,
> >>> Priya Ahuja
> >>>
> >>>
> >>>
> >>> On Tue, Aug 4, 2015 at 12:36 PM, Gary Gregory <ga...@gmail.com>
> >>> wrote:
> >>>
> >>>> Hi Priya,
> >>>>
> >>>> What is your configuration? What version are you using?
> >>>>
> >>>> Gary
> >>>>
> >>>> On Tue, Aug 4, 2015 at 12:30 PM, Priya Ahuja <pr...@gmail.com>
> >>>> wrote:
> >>>>
> >>>>> Hi,
> >>>>>
> >>>>> I am trying to add structured data using includeMDC and loggerfields
> >>>> but I
> >>>>> also want MESSAGE-ID passed by the user in the log.
> >>>>>
> >>>>> *My current implementation:*
> >>>>> I am passing StructuredDataMessage to logIfEnabled since that is the
> >>>> only
> >>>>> way to pass user defined message-id
> >>>>>       - StructuredDataMessage((String)null, msg, messageId)
> >>>>>
> >>>>> But I want the structured data picked up from* XML configuration:*
> >>>>>
> >>>>>        <Syslog name="RFC5424" format="RFC5424" enterpriseNumber=6876
> >>>>>               * id="LS" includeMDC="true" mdcId="enterprise"*
> >>>>>                mdcIncludes="comp,subcomp">
> >>>>>                <LoggerFields>
> >>>>>                    <KeyValuePair key="level" value="dummy" />
> >>>>>                    <KeyValuePair key="id" value="dummy" />
> >>>>>                </LoggerFields>
> >>>>>
> >>>>> As a result my structured data appears twice in the log:
> >>>>> <182>1 2015-08-03T20:28:16.413Z localhost - - USER *[enterprise@6876
> >>>>> level="dummy" id="dummy"][@6876] *This is a dummy log
> >>>>>
> >>>>> Any help appreciated.
> >>>>>
> >>>>> Thanks,
> >>>>> Priya Ahuja
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> >>>> Java Persistence with Hibernate, Second Edition
> >>>> <http://www.manning.com/bauer3/>
> >>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> >>>> Spring Batch in Action <http://www.manning.com/templier/>
> >>>> Blog: http://garygregory.wordpress.com
> >>>> Home: http://garygregory.com/
> >>>> Tweet! http://twitter.com/GaryGregory
> >>>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >>> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>>
> >>
> >>
> >>
> >> --
> >> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> >> Java Persistence with Hibernate, Second Edition
> >> <http://www.manning.com/bauer3/>
> >> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> >> Spring Batch in Action <http://www.manning.com/templier/>
> >> Blog: http://garygregory.wordpress.com
> >> Home: http://garygregory.com/
> >> Tweet! http://twitter.com/GaryGregory
> >>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: Structured data appearing twice

Posted by Ralph Goers <ra...@dslextreme.com>.
Can you describe your use case in a bit more detail?  Maybe we can provide some other ideas on how to resolve it.

Ralph

> On Sep 15, 2015, at 12:17 PM, Priya Ahuja <pr...@gmail.com> wrote:
> 
> Thanks Gary! I will update after trying with 2.3. I have a mild idea on
> what may be going wrong. My requirement is that I need userdefined id
> (messageid) and configuration based structured data.
> 
> 1. Messageid is only parsed in log4j if the message is an instance of
> StructuredDataMessage, hence I am forced to send my message to log4j as
> structuredDataMessage with empty Map for structured data
> 2. As a result, the final message gets parsed indexed with two maps, once
> from the config file and other from the message itself
> 
> Thanks,
> Priya Ahuja
> 
> On Mon, Sep 14, 2015 at 7:57 PM, Gary Gregory <ga...@gmail.com>
> wrote:
> 
>> Can you try version 2.3 or 2.4 out of Git master?
>> 
>> Gary
>> 
>> On Tue, Aug 4, 2015 at 1:41 PM, Priya Ahuja <pr...@gmail.com> wrote:
>> 
>>> Hi Gary,
>>> 
>>> I am currently using version 2.1.
>>> 
>>> I have attached the log4j configuration file.
>>> 
>>> Thanks,
>>> Priya Ahuja
>>> 
>>> 
>>> 
>>> On Tue, Aug 4, 2015 at 12:36 PM, Gary Gregory <ga...@gmail.com>
>>> wrote:
>>> 
>>>> Hi Priya,
>>>> 
>>>> What is your configuration? What version are you using?
>>>> 
>>>> Gary
>>>> 
>>>> On Tue, Aug 4, 2015 at 12:30 PM, Priya Ahuja <pr...@gmail.com>
>>>> wrote:
>>>> 
>>>>> Hi,
>>>>> 
>>>>> I am trying to add structured data using includeMDC and loggerfields
>>>> but I
>>>>> also want MESSAGE-ID passed by the user in the log.
>>>>> 
>>>>> *My current implementation:*
>>>>> I am passing StructuredDataMessage to logIfEnabled since that is the
>>>> only
>>>>> way to pass user defined message-id
>>>>>       - StructuredDataMessage((String)null, msg, messageId)
>>>>> 
>>>>> But I want the structured data picked up from* XML configuration:*
>>>>> 
>>>>>        <Syslog name="RFC5424" format="RFC5424" enterpriseNumber=6876
>>>>>               * id="LS" includeMDC="true" mdcId="enterprise"*
>>>>>                mdcIncludes="comp,subcomp">
>>>>>                <LoggerFields>
>>>>>                    <KeyValuePair key="level" value="dummy" />
>>>>>                    <KeyValuePair key="id" value="dummy" />
>>>>>                </LoggerFields>
>>>>> 
>>>>> As a result my structured data appears twice in the log:
>>>>> <182>1 2015-08-03T20:28:16.413Z localhost - - USER *[enterprise@6876
>>>>> level="dummy" id="dummy"][@6876] *This is a dummy log
>>>>> 
>>>>> Any help appreciated.
>>>>> 
>>>>> Thanks,
>>>>> Priya Ahuja
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>> Java Persistence with Hibernate, Second Edition
>>>> <http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com
>>>> Home: http://garygregory.com/
>>>> Tweet! http://twitter.com/GaryGregory
>>>> 
>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>>> 
>> 
>> 
>> 
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>> 



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


Re: Structured data appearing twice

Posted by Priya Ahuja <pr...@gmail.com>.
Thanks Gary! I will update after trying with 2.3. I have a mild idea on
what may be going wrong. My requirement is that I need userdefined id
(messageid) and configuration based structured data.

1. Messageid is only parsed in log4j if the message is an instance of
StructuredDataMessage, hence I am forced to send my message to log4j as
structuredDataMessage with empty Map for structured data
2. As a result, the final message gets parsed indexed with two maps, once
from the config file and other from the message itself

Thanks,
Priya Ahuja

On Mon, Sep 14, 2015 at 7:57 PM, Gary Gregory <ga...@gmail.com>
wrote:

> Can you try version 2.3 or 2.4 out of Git master?
>
> Gary
>
> On Tue, Aug 4, 2015 at 1:41 PM, Priya Ahuja <pr...@gmail.com> wrote:
>
> > Hi Gary,
> >
> > I am currently using version 2.1.
> >
> > I have attached the log4j configuration file.
> >
> > Thanks,
> > Priya Ahuja
> >
> >
> >
> > On Tue, Aug 4, 2015 at 12:36 PM, Gary Gregory <ga...@gmail.com>
> > wrote:
> >
> >> Hi Priya,
> >>
> >> What is your configuration? What version are you using?
> >>
> >> Gary
> >>
> >> On Tue, Aug 4, 2015 at 12:30 PM, Priya Ahuja <pr...@gmail.com>
> >> wrote:
> >>
> >> > Hi,
> >> >
> >> > I am trying to add structured data using includeMDC and loggerfields
> >> but I
> >> > also want MESSAGE-ID passed by the user in the log.
> >> >
> >> > *My current implementation:*
> >> > I am passing StructuredDataMessage to logIfEnabled since that is the
> >> only
> >> > way to pass user defined message-id
> >> >        - StructuredDataMessage((String)null, msg, messageId)
> >> >
> >> > But I want the structured data picked up from* XML configuration:*
> >> >
> >> >         <Syslog name="RFC5424" format="RFC5424" enterpriseNumber=6876
> >> >                * id="LS" includeMDC="true" mdcId="enterprise"*
> >> >                 mdcIncludes="comp,subcomp">
> >> >                 <LoggerFields>
> >> >                     <KeyValuePair key="level" value="dummy" />
> >> >                     <KeyValuePair key="id" value="dummy" />
> >> >                 </LoggerFields>
> >> >
> >> > As a result my structured data appears twice in the log:
> >> > <182>1 2015-08-03T20:28:16.413Z localhost - - USER *[enterprise@6876
> >> > level="dummy" id="dummy"][@6876] *This is a dummy log
> >> >
> >> > Any help appreciated.
> >> >
> >> > Thanks,
> >> > Priya Ahuja
> >> >
> >>
> >>
> >>
> >> --
> >> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> >> Java Persistence with Hibernate, Second Edition
> >> <http://www.manning.com/bauer3/>
> >> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> >> Spring Batch in Action <http://www.manning.com/templier/>
> >> Blog: http://garygregory.wordpress.com
> >> Home: http://garygregory.com/
> >> Tweet! http://twitter.com/GaryGregory
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>

Re: Structured data appearing twice

Posted by Gary Gregory <ga...@gmail.com>.
Can you try version 2.3 or 2.4 out of Git master?

Gary

On Tue, Aug 4, 2015 at 1:41 PM, Priya Ahuja <pr...@gmail.com> wrote:

> Hi Gary,
>
> I am currently using version 2.1.
>
> I have attached the log4j configuration file.
>
> Thanks,
> Priya Ahuja
>
>
>
> On Tue, Aug 4, 2015 at 12:36 PM, Gary Gregory <ga...@gmail.com>
> wrote:
>
>> Hi Priya,
>>
>> What is your configuration? What version are you using?
>>
>> Gary
>>
>> On Tue, Aug 4, 2015 at 12:30 PM, Priya Ahuja <pr...@gmail.com>
>> wrote:
>>
>> > Hi,
>> >
>> > I am trying to add structured data using includeMDC and loggerfields
>> but I
>> > also want MESSAGE-ID passed by the user in the log.
>> >
>> > *My current implementation:*
>> > I am passing StructuredDataMessage to logIfEnabled since that is the
>> only
>> > way to pass user defined message-id
>> >        - StructuredDataMessage((String)null, msg, messageId)
>> >
>> > But I want the structured data picked up from* XML configuration:*
>> >
>> >         <Syslog name="RFC5424" format="RFC5424" enterpriseNumber=6876
>> >                * id="LS" includeMDC="true" mdcId="enterprise"*
>> >                 mdcIncludes="comp,subcomp">
>> >                 <LoggerFields>
>> >                     <KeyValuePair key="level" value="dummy" />
>> >                     <KeyValuePair key="id" value="dummy" />
>> >                 </LoggerFields>
>> >
>> > As a result my structured data appears twice in the log:
>> > <182>1 2015-08-03T20:28:16.413Z localhost - - USER *[enterprise@6876
>> > level="dummy" id="dummy"][@6876] *This is a dummy log
>> >
>> > Any help appreciated.
>> >
>> > Thanks,
>> > Priya Ahuja
>> >
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> Java Persistence with Hibernate, Second Edition
>> <http://www.manning.com/bauer3/>
>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>> Spring Batch in Action <http://www.manning.com/templier/>
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Structured data appearing twice

Posted by Priya Ahuja <pr...@gmail.com>.
Hi Gary,

I am currently using version 2.1.

I have attached the log4j configuration file.

Thanks,
Priya Ahuja



On Tue, Aug 4, 2015 at 12:36 PM, Gary Gregory <ga...@gmail.com>
wrote:

> Hi Priya,
>
> What is your configuration? What version are you using?
>
> Gary
>
> On Tue, Aug 4, 2015 at 12:30 PM, Priya Ahuja <pr...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I am trying to add structured data using includeMDC and loggerfields but
> I
> > also want MESSAGE-ID passed by the user in the log.
> >
> > *My current implementation:*
> > I am passing StructuredDataMessage to logIfEnabled since that is the only
> > way to pass user defined message-id
> >        - StructuredDataMessage((String)null, msg, messageId)
> >
> > But I want the structured data picked up from* XML configuration:*
> >
> >         <Syslog name="RFC5424" format="RFC5424" enterpriseNumber=6876
> >                * id="LS" includeMDC="true" mdcId="enterprise"*
> >                 mdcIncludes="comp,subcomp">
> >                 <LoggerFields>
> >                     <KeyValuePair key="level" value="dummy" />
> >                     <KeyValuePair key="id" value="dummy" />
> >                 </LoggerFields>
> >
> > As a result my structured data appears twice in the log:
> > <182>1 2015-08-03T20:28:16.413Z localhost - - USER *[enterprise@6876
> > level="dummy" id="dummy"][@6876] *This is a dummy log
> >
> > Any help appreciated.
> >
> > Thanks,
> > Priya Ahuja
> >
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>

Re: Structured data appearing twice

Posted by Gary Gregory <ga...@gmail.com>.
Hi Priya,

What is your configuration? What version are you using?

Gary

On Tue, Aug 4, 2015 at 12:30 PM, Priya Ahuja <pr...@gmail.com> wrote:

> Hi,
>
> I am trying to add structured data using includeMDC and loggerfields but I
> also want MESSAGE-ID passed by the user in the log.
>
> *My current implementation:*
> I am passing StructuredDataMessage to logIfEnabled since that is the only
> way to pass user defined message-id
>        - StructuredDataMessage((String)null, msg, messageId)
>
> But I want the structured data picked up from* XML configuration:*
>
>         <Syslog name="RFC5424" format="RFC5424" enterpriseNumber=6876
>                * id="LS" includeMDC="true" mdcId="enterprise"*
>                 mdcIncludes="comp,subcomp">
>                 <LoggerFields>
>                     <KeyValuePair key="level" value="dummy" />
>                     <KeyValuePair key="id" value="dummy" />
>                 </LoggerFields>
>
> As a result my structured data appears twice in the log:
> <182>1 2015-08-03T20:28:16.413Z localhost - - USER *[enterprise@6876
> level="dummy" id="dummy"][@6876] *This is a dummy log
>
> Any help appreciated.
>
> Thanks,
> Priya Ahuja
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory