[image: Inline image 1]
[image: Inline image 2]

On Wed, Oct 9, 2013 at 3:05 PM, Ralph Goers <[email protected]>wrote:

> Can you provide your lookup source?
>
>
> On Oct 9, 2013, at 1:22 PM, Jonathan Willis <[email protected]>
> wrote:
>
> >
> http://stackoverflow.com/questions/19277445/how-to-use-map-lookups-using-log4j2
> >
> >
> > On Wed, Oct 9, 2013 at 2:18 PM, Ralph Goers <[email protected]
> >wrote:
> >
> >> Please remember that mine is just one opinion, but I am fine with that.
>  I
> >> guess if no default value is provided this way then it can still fall
> back
> >> to looking in the properties map.
> >>
> >> Ralph
> >>
> >>
> >> On Oct 9, 2013, at 12:53 PM, Woonsan Ko <[email protected]> wrote:
> >>
> >>> Hi Ralph,
> >>>
> >>>
> >>> I have something related to this improvement idea.
> >>> I have thought it might be a bit more useful and flexible to allow
> >> default value in the variable expression itself.
> >>> For example, ${var1:-defvalue1}, ${ctx:request_id:-defvalue2}, etc.
> >>> This generic feature has been included in StrSubstitutor of
> >> commons-lang3 with the following issue:
> >>> - https://issues.apache.org/jira/browse/LANG-893
> >>>
> >>> I understand Oliver's patch should work more efficiently for map
> pattern
> >> converters, but the goodness of the feature with LANG-893 is we can use
> it
> >> more widely whenever used in look ups.
> >>>
> >>> I know StrSubstitutor in log4j2 added more operations to deal with
> >> LogEvent argument, so I can create a patch to include the feature of
> >> LANG-893 if it is useful for others.
> >>> Also, Oliver's patch won't conflict with this patch.
> >>>
> >>> What do you think?
> >>>
> >>> Kind regards,
> >>>
> >>> Woonsan
> >>>
> >>>
> >>>> On Tuesday, October 1, 2013 9:21 AM, Ralph Goers <[email protected]>
> >> wrote:
> >>>>> Patches are always welcome!
> >>>>
> >>>> Ralph
> >>>>
> >>>> On Oct 1, 2013, at 1:13 AM, Oliver Flege <[email protected]> wrote:
> >>>>
> >>>>>> $${mdc:request_id} in a pattern should cause the request_id to be
> >>>> evaluated on every event.
> >>>>>
> >>>>> thanks a lot, $${ctx:request_id} seems to do the trick
> >>>>>
> >>>>> however, the computation of the default value is quite complex as it
> >> always
> >>>> involves
> >>>>> a variable substitution, and I cannot use conversion specifiers with
> >> $$ as
> >>>> I can with %X
> >>>>>
> >>>>> Would you consider accepting a patch that adds support for slf4j-like
> >>>> default values
> >>>>> in %X{key} and %K{key}, s.th. like %X{key:-defaultValue} ?
> >>>>>
> >>>>> Regards,
> >>>>> Oliver
> >>>>>
> >>>>>
> >>>>>
> >>>>>>
> >>>>>>> On Sep 30, 2013, at 8:04 AM, Oliver Flege <[email protected]>
> >>>> wrote:
> >>>>>>>
> >>>>>>> ok, this works for ${...} expressions in the configuration,
> >>>> but I don't see how it would
> >>>>>>> apply to pattern evaluation. To simplify and rephrase my original
> >>>> question:
> >>>>>>>
> >>>>>>> Given a pattern layout with a pattern like:  %X{REQUEST_ID}
> >>>>>>>
> >>>>>>> is it possible to define a default value that will be printed
> >>>>>>> if the thread never executed
> >>>> ThreadContext.put("REQUEST_ID", "XYZ")?
> >>>>>>>
> >>>>>>> I tried ${mdc:REQUEST_ID} + a Property REQUEST_ID, but that
> >>>>>>> will only be evaluated when the configuration is parsed.
> >>>>>>>
> >>>>>>> Oliver
> >>>>>>>
> >>>>>>>> Yes, it supports default values. Specify them as properties at
> >>>> the beginning of your configuration. Then when you specify something
> >> like
> >>>> ${sys:foo} if foo is not defined as a system property the default
> value
> >>>> will be used,
> >>>>>>>>
> >>>>>>>> Ralph
> >>>>>>>>
> >>>>>>>>> On Sep 30, 2013, at 3:30 AM, Oliver Flege
> >>>> <[email protected]> wrote:
> >>>>>>>>>
> >>>>>>>>> Hi,
> >>>>>>>>>
> >>>>>>>>> I am considering to switch from slf4j/logback to log4j2;
> >>>>>>>>>
> >>>>>>>>> in slf4j/logback, I can specify a default value for a
> >>>> missing mdc entry
> >>>>>>>>> like this:
> >>>>>>>>>
> >>>>>>>>> <pattern>%d{HH:mm:ss} %X{FOO:--} %c{0}
> >>>> - %m%n</pattern>
> >>>>>>>>>
> >>>>>>>>> which would print "-" if mdc.get("FOO")
> >>>> is null (the ":-" separates
> >>>>>>>>> the key and the default value).
> >>>>>>>>>
> >>>>>>>>> Having a defined number of tokens/fields at the beginning
> >>>> of the log message
> >>>>>>>>> makes it easier to process it with awk/cut etc.
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Does log4j support default values? - I could not find any
> >>>> hint in the documentation
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Regards,
> >>>>>>>>> Oliver
> >>>>>>>>>
> >>>>>>>>>
> >>>> ---------------------------------------------------------------------
> >>>>>>>>> To unsubscribe, e-mail:
> >>>> [email protected]
> >>>>>>>>> For additional commands, e-mail:
> >>>> [email protected]
> >>>>>>>>
> >>>>>>>>
> >>>> ---------------------------------------------------------------------
> >>>>>>>> To unsubscribe, e-mail:
> >>>> [email protected]
> >>>>>>>> For additional commands, e-mail:
> >>>> [email protected]
> >>>>>>>
> >>>>>>>
> >>>>>>> --
> >>>>>>> Oliver Flege
> >>>>>>> Senior Software Engineer | vwd group
> >>>>>>>
> >>>>>>> vwd Vereinigte Wirtschaftsdienste AG
> >>>>>>> Stiftsplatz 6/7 | 67655 Kaiserslautern
> >>>>>>> Telefon: +49 631 3649-0 | Telefax: +49 631 3649-109
> >>>>>>> [email protected] | www.vwd.com
> >>>>>>> ______________________________________________________________
> >>>>>>>
> >>>>>>> vwd Vereinigte Wirtschaftsdienste AG
> >>>>>>> Sitz der Gesellschaft: Tilsiter Straße 1 | 60487 Frankfurt am Main
> >>>>>>> Handelsregister: AG Frankfurt am Main HRB 81011
> >>>>>>> Vorstand: Dr. Ralf Kauther
> >>>>>>> Vorsitzender des Aufsichtsrates: Dr. Thorsten Dippel
> >>>>
> >>>>>>> ____________________________________________________________
> >>>>>>>
> >>>>>>>
> >>>> ---------------------------------------------------------------------
> >>>>>>> To unsubscribe, e-mail: [email protected]
> >>>>>>> For additional commands, e-mail:
> [email protected]
> >>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>> To unsubscribe, e-mail: [email protected]
> >>>>>> For additional commands, e-mail: [email protected]
> >>>>>
> >>>>>
> >>>>> --
> >>>>> Oliver Flege
> >>>>> Senior Software Engineer | vwd group
> >>>>>
> >>>>> vwd Vereinigte Wirtschaftsdienste AG
> >>>>> Stiftsplatz 6/7 | 67655 Kaiserslautern
> >>>>> Telefon: +49 631 3649-0 | Telefax: +49 631 3649-109
> >>>>> [email protected] | www.vwd.com
> >>>>> ______________________________________________________________
> >>>>>
> >>>>> vwd Vereinigte Wirtschaftsdienste AG
> >>>>> Sitz der Gesellschaft: Tilsiter Straße 1 | 60487 Frankfurt am Main
> >>>>> Handelsregister: AG Frankfurt am Main HRB 81011
> >>>>> Vorstand: Dr. Ralf Kauther
> >>>>> Vorsitzender des Aufsichtsrates: Dr. Thorsten Dippel
> >>>>> ____________________________________________________________
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: [email protected]
> >>>>> For additional commands, e-mail: [email protected]
> >>>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: [email protected]
> >>>> For additional commands, e-mail: [email protected]
> >>>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [email protected]
> >>> For additional commands, e-mail: [email protected]
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [email protected]
> >> For additional commands, e-mail: [email protected]
> >>
> >>
> >
> >
> > --
> > Jonathan Willis
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Jonathan Willis

Reply via email to