Re: Context data propagation and logger-bound context data

2024-04-15 Thread Ralph Goers
In theory that library could use the ContextData class I just added to get context data no matter how it got there. However, the Micrometer library’s setValue and getValue set and retrieve the full map, not values. That won’t play nice with a ScopedContext since once you set it you would immedia

Re: Context data propagation and logger-bound context data

2024-04-15 Thread Piotr P. Karwasz
Hi, On Mon, 15 Apr 2024 at 18:44, Matt Sicker wrote: > Context Propagation support :: Micrometer Context Propagation > > docs.micrometer.io > > [image: favicon.ico] >

Re: Context data propagation and logger-bound context data

2024-04-15 Thread Matt Sicker
https://docs.micrometer.io/context-propagation/reference/ This is more in line with what I was thinking we should support. I’m not suggesting that we add Micrometer as a dependency to the API or Core, but we can replicate the minimal API here or figure out a smaller API for integration purpose

Re: Context data propagation and logger-bound context data

2024-03-27 Thread Ralph Goers
Volkan, No more hand waving. Please see https://github.com/apache/logging-log4j2/pull/2419. I should note that while implementing the classes I added to support this makes it easier I did not have to make any changes to the logging internals to make this work. Ralph > On Mar 22, 2024, at 1:4

Re: Context data propagation and logger-bound context data

2024-03-22 Thread Ralph Goers
> On Mar 22, 2024, at 1:45 AM, Volkan Yazıcı wrote: > > No, it is not the same thing Matt. Let me be as explicit as I can: > > var logger0 = getLogger(); // MDC: {} > var logger1 = logger0.withContextData("x", 1); // MDC: {x: 1} > var logger2 = logger1.withContextData("y", 2); // MDC: {x: 1

Re: Context data propagation and logger-bound context data

2024-03-22 Thread Piotr P. Karwasz
Hi Volkan, On Fri, 22 Mar 2024 at 09:45, Volkan Yazıcı wrote: > *P.S.* For Log4j 3 API Javadocs, you can browse to > https://logging.apache.org/log4j/3.x and search for "Javadoc" in the > menu. (Obviously, same works for Log4j 2 too.) > You can also Google "log4j javadoc" now! Apparently our 30

Re: Context data propagation and logger-bound context data

2024-03-22 Thread Volkan Yazıcı
No, it is not the same thing Matt. Let me be as explicit as I can: var logger0 = getLogger(); // MDC: {} var logger1 = logger0.withContextData("x", 1); // MDC: {x: 1} var logger2 = logger1.withContextData("y", 2); // MDC: {x: 1, y: 2} This is the functionality being requested. Whoever claims t

Re: Context data propagation and logger-bound context data

2024-03-22 Thread Piotr P. Karwasz
Hi Ralph, On Fri, 22 Mar 2024 at 03:08, Ralph Goers wrote: > > On Mar 21, 2024, at 3:19 PM, Piotr P. Karwasz > > wrote: > > > > > > PS: In the `main` branch I plan to replace the default > > ReusableMessageFactory with ReusableLogEventFactory: > > > > * this change should have a minimal impact

Re: Context data propagation and logger-bound context data

2024-03-21 Thread Raman Gupta
On Thu, Mar 21, 2024 at 9:58 PM Ralph Goers wrote: > > > On Mar 21, 2024, at 2:48 PM, Raman Gupta wrote: > > > > On Thu, Mar 21, 2024 at 5:30 AM Piotr P. Karwasz < > piotr.karw...@gmail.com> > > wrote: > > > >> Hi Ralph, > >> > >> On Thu, 21 Mar 2024 at 07:03, Ralph Goers > >> wrote: > 1.

Re: Context data propagation and logger-bound context data

2024-03-21 Thread Ralph Goers
> On Mar 21, 2024, at 3:19 PM, Piotr P. Karwasz wrote: > > > PS: In the `main` branch I plan to replace the default > ReusableMessageFactory with ReusableLogEventFactory: > > * this change should have a minimal impact on memory (events are not > much larger than messages), > * it can skip a

Re: Context data propagation and logger-bound context data

2024-03-21 Thread Ralph Goers
> On Mar 21, 2024, at 2:48 PM, Raman Gupta wrote: > > On Thu, Mar 21, 2024 at 5:30 AM Piotr P. Karwasz > wrote: > >> Hi Ralph, >> >> On Thu, 21 Mar 2024 at 07:03, Ralph Goers >> wrote: 1. Raman and Mikko would like to bind context data to an object implementing the `Logger` inter

Re: Context data propagation and logger-bound context data

2024-03-21 Thread Raman Gupta
On Thu, Mar 21, 2024 at 6:19 PM Piotr P. Karwasz wrote: > Hi Raman, > > On Thu, 21 Mar 2024 at 22:51, Raman Gupta wrote: > > > > For example, a User could configure a custom MessageFactory that > > > provides an extension of MapMessage that causes the message to include > data > > > from the cla

Re: Context data propagation and logger-bound context data

2024-03-21 Thread Piotr P. Karwasz
Hi Raman, On Thu, 21 Mar 2024 at 22:51, Raman Gupta wrote: > > > For example, a User could configure a custom MessageFactory that > > provides an extension of MapMessage that causes the message to include data > > from the class or resource. Going to the extreme of trying to shoehorn in > > Conte

Re: Context data propagation and logger-bound context data

2024-03-21 Thread Raman Gupta
On Thu, Mar 21, 2024 at 5:30 AM Piotr P. Karwasz wrote: > Hi Ralph, > > On Thu, 21 Mar 2024 at 07:03, Ralph Goers > wrote: > > > 1. Raman and Mikko would like to bind context data to an object > > > implementing the `Logger` interface or more generally to a service > > > object (e.g. resource ma

Re: Context data propagation and logger-bound context data

2024-03-21 Thread Matt Sicker
https://www.javadoc.io/doc/org.apache.logging.log4j/log4j-api/3.0.0-alpha1/org.apache.logging.log4j/org/apache/logging/log4j/LogManager.html Pass your custom MessageFactory here. It’s an optional argument when creating the Logger. Also, I’m not sure where to even find the current javadocs for t

Re: Context data propagation and logger-bound context data

2024-03-21 Thread Volkan Yazıcı
Ralph, could you show how those two users can use a `MessageFactory` to create `Logger`s with predefined additional context data? On Thu, Mar 21, 2024 at 7:25 AM Ralph Goers wrote: > Unfortunately this is another message I somehow didn't get in my inbox. > Replying to it via lists.a.o is not a g

Re: Context data propagation and logger-bound context data

2024-03-21 Thread Piotr P. Karwasz
Hi Ralph, On Thu, 21 Mar 2024 at 07:03, Ralph Goers wrote: > > 1. Raman and Mikko would like to bind context data to an object > > implementing the `Logger` interface or more generally to a service > > object (e.g. resource manager, DAO and variants), > > Yes, I’ve seen that. Personally, I am not

Re: Context data propagation and logger-bound context data

2024-03-21 Thread Piotr P. Karwasz
Hi Ralph, On Wed, 20 Mar 2024 at 17:11, Ralph Goers wrote: > > 1. I am experimenting with adding Thread support to ScopedContext as we > speak. It should be straightforward. > > I am not sure we ever want to deal with ScopedValue. ScopedContext provides > the same functionality plus integration

Re: Context data propagation and logger-bound context data

2024-03-20 Thread Ralph Goers
Unfortunately this is another message I somehow didn't get in my inbox. Replying to it via lists.a.o is not a great experience but is the best I can do. On 2024/03/20 13:51:56 Volkan Yazıcı wrote: > I agree with the way Piotr dissects the problem. I think `ScopedContext`, > even though it has its

Re: Context data propagation and logger-bound context data

2024-03-20 Thread Ralph Goers
> On Mar 18, 2024, at 2:39 AM, Piotr P. Karwasz wrote: > > Hi, > > Given the ongoing context data propagation in three Github > issues/PRs/discussions (cf. [1], [2] and [3]). I think we should move > the debate to the mailing list, which guarantees the maximal reachout. > > == Problem summar

Re: Context data propagation and logger-bound context data

2024-03-20 Thread Ralph Goers
1. I am experimenting with adding Thread support to ScopedContext as we speak. It should be straightforward. I am not sure we ever want to deal with ScopedValue. ScopedContext provides the same functionality plus integration with logging. Ralph > On Mar 20, 2024, at 4:22 AM, Piotr P. Karwasz

Re: Context data propagation and logger-bound context data

2024-03-20 Thread Volkan Yazıcı
I agree with the way Piotr dissects the problem. I think `ScopedContext`, even though it has its own merits, doesn't address the problem reported by users. They simply want a new logger associated with some additional context data. *[See my comments below.]* On Mon, Mar 18, 2024 at 10:40 AM Piotr

Re: Context data propagation and logger-bound context data

2024-03-20 Thread Piotr P. Karwasz
Hi Ralph, On Tue, 19 Mar 2024 at 07:45, Ralph Goers wrote: > 2. The links you provide describe the problem of passing contexts to threads > magnificently. Unfortunately, they solve it by requiring you NOT to use > standard JDK tooling for managing threads. I am not prepared to be dependent > o

Re: Context data propagation and logger-bound context data

2024-03-18 Thread Ralph Goers
First, lets consider the two usages you highlighted 1. In theory it is possible to add properties to a Logger. In practice, we only allow this from the LoggerConfig. While the values of those properties can include Lookup references this isn’t going to help much since there is no way for the Lo

Context data propagation and logger-bound context data

2024-03-18 Thread Piotr P. Karwasz
Hi, Given the ongoing context data propagation in three Github issues/PRs/discussions (cf. [1], [2] and [3]). I think we should move the debate to the mailing list, which guarantees the maximal reachout. == Problem summary We have two different problems regarding context data in log files: 1. R