You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "andreycha (via GitHub)" <gi...@apache.org> on 2023/04/26 08:40:03 UTC

[GitHub] [logging-log4net] andreycha opened a new pull request, #101: Add Peek() method to ThreadContextStack and LogicalThreadContextStack.

andreycha opened a new pull request, #101:
URL: https://github.com/apache/logging-log4net/pull/101

   **Change**
   Add `Peek()` method to `ThreadContextStack` and `LogicalThreadContextStack` to be able to get the most recent value from the context without removing it.
   
   **Motivation**
   In the scope of [ElasticCommonSchema .NET integration for log4net](https://github.com/elastic/ecs-dotnet/tree/main/src/Elastic.CommonSchema.Log4net) log entry properties are being read and written to ECS format. In case of context stacks [current implementation](https://github.com/elastic/ecs-dotnet/blob/main/src/Elastic.CommonSchema.Log4net/LoggingEventConverter.cs#L85) takes string representation of the stack. It works fine when stack (i.e., property) has a single value, but there are also cases when stack contains multiple values (same or different ones). With the proposed changes it will be able to take the most recent value, in the context of which the current log entry is being written.
   
   Consider following scenario:
   
   ```cs
   using (var _ = LogicalThreadContext.Stacks["Id"].Push("123"))
   {
       log.Info("Log 1"); // currently has "123" in the log metadata
   
       using (var __ = LogicalThreadContext.Stacks["Id"].Push("456"))
       {
           log.Info("Log 2"); // currently has "123 456" in the log metadata; should have "456" instead
   
           using (var ___ = LogicalThreadContext.Stacks["Id"].Push("789"))
           {
               log.Info("Log 3"); // currently has "123 456 789" in the log metadata; should have "789" instead
           }
       }
   }
   ```
   
   **Alternative solutions considered**
   An alternative approach might be to just pop the most recent value and then push it again onto the stack. Problem here is that it creates a new scope which will not be closed as no one will call `Dispose()` on the returned result from `Push()`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4net] andreycha commented on pull request #101: Add Peek() method to ThreadContextStack and LogicalThreadContextStack.

Posted by "andreycha (via GitHub)" <gi...@apache.org>.
andreycha commented on PR #101:
URL: https://github.com/apache/logging-log4net/pull/101#issuecomment-1537209712

   Yeah, I can relate. Anyway, looking forward to the new release!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4net] fluffynuts merged pull request #101: Add Peek() method to ThreadContextStack and LogicalThreadContextStack.

Posted by "fluffynuts (via GitHub)" <gi...@apache.org>.
fluffynuts merged PR #101:
URL: https://github.com/apache/logging-log4net/pull/101


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4net] fluffynuts commented on pull request #101: Add Peek() method to ThreadContextStack and LogicalThreadContextStack.

Posted by "fluffynuts (via GitHub)" <gi...@apache.org>.
fluffynuts commented on PR #101:
URL: https://github.com/apache/logging-log4net/pull/101#issuecomment-1535316045

   @andreycha I guess you could sub to apache logging email lists; but I really want to figure out a way to do beta releases, and I doubt they'd go through that, so :shrug: I haven't figured this out yet ): I have this tension between "actual releases are a major mission with a lot of dead time whilst I wait for a bunch of Java people to vote on a dotnet thing that they have no context about" and "I just want to release fixes" )':


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4net] andreycha commented on pull request #101: Add Peek() method to ThreadContextStack and LogicalThreadContextStack.

Posted by "andreycha (via GitHub)" <gi...@apache.org>.
andreycha commented on PR #101:
URL: https://github.com/apache/logging-log4net/pull/101#issuecomment-1533006551

   Thanks! Is there a way to somehow get notified when a new release comes out?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4net] andreycha commented on pull request #101: Add Peek() method to ThreadContextStack and LogicalThreadContextStack.

Posted by "andreycha (via GitHub)" <gi...@apache.org>.
andreycha commented on PR #101:
URL: https://github.com/apache/logging-log4net/pull/101#issuecomment-1532620723

   Hi @fluffynuts , could you please check this PR? Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org