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 Mikael Ståldal <mi...@magine.com> on 2016/10/18 15:46:04 UTC
ContextData / StringMap, non-String values and Thread Context
As part of https://issues.apache.org/jira/browse/LOG4J2-1447 we added
support for non-String values in log event's context data (with the
org.apache.logging.log4j.util.StringMap interface).
However, as far as I can see, we do not leverage the possibility to use
non-String values anywhere. Do we have any plans to do that? Such as a
putValue(String key, Object value) method in org.apache.logging.log4j.
ThreadContext?
--
[image: MagineTV]
*Mikael Ståldal*
Senior software developer
*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.
Re: ContextData / StringMap, non-String values and Thread Context
Posted by Gary Gregory <ga...@gmail.com>.
We also still use code that we deprecated...
On Tue, Oct 18, 2016 at 8:46 AM, Mikael Ståldal <mi...@magine.com>
wrote:
> As part of https://issues.apache.org/jira/browse/LOG4J2-1447 we added
> support for non-String values in log event's context data (with the
> org.apache.logging.log4j.util.StringMap interface).
>
> However, as far as I can see, we do not leverage the possibility to use
> non-String values anywhere. Do we have any plans to do that? Such as a
> putValue(String key, Object value) method in org.apache.logging.log4j.
> ThreadContext?
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
JUnit in Action, Second Edition
<https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
Spring Batch in Action
<https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Re: ContextData / StringMap, non-String values and Thread Context
Posted by Remko Popma <re...@gmail.com>.
By providing a StringMap interface that allows Object values we unlocked numerous custom extensions that the previous Map<String, String> interface did not allow.
However the public API should probably stay restricted to String values, at least for now. This is to prevent memory leaks in web applications: in web applications ThreadLocals should only contain JDK classes.
We may be able to add a public ThreadContext::putValue(String, Object) method after https://issues.apache.org/jira/browse/LOG4J2-1116 has been addressed.
Remko
Sent from my iPhone
> On 19 Oct 2016, at 0:46, Mikael Ståldal <mi...@magine.com> wrote:
>
> As part of https://issues.apache.org/jira/browse/LOG4J2-1447 we added support for non-String values in log event's context data (with the org.apache.logging.log4j.util.StringMap interface).
>
> However, as far as I can see, we do not leverage the possibility to use non-String values anywhere. Do we have any plans to do that? Such as a putValue(String key, Object value) method in org.apache.logging.log4j.ThreadContext?
>
> --
>
>
> Mikael Ståldal
> Senior software developer
>
> Magine TV
> mikael.staldal@magine.com
> Grev Turegatan 3 | 114 46 Stockholm, Sweden | www.magine.com
>
> Privileged and/or Confidential Information may be contained in this message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply email.