GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add Peek() method to ThreadContextStack and LogicalThreadContextStack. by andreycha · Pull Request #101 · apache/logging-log4net

Conversation

@andreycha

@andreycha andreycha commented Apr 26, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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 log entry properties are being read and written to ECS format. In case of context stacks current implementation 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:

using (LogicalThreadContext.Stacks["Id"].Push("123"))
{
    log.Info("Log 1"); // currently has "123" in the log metadata

    using (LogicalThreadContext.Stacks["Id"].Push("456"))
    {
        log.Info("Log 2"); // currently has "123 456" in the log metadata; should have "456" instead

        using (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().

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
stt-anch added 3 commits April 26, 2023 10:25
@stt-anch
Add Peek() method to ThreadContextStack and LogicalThreadContextStack.
ea29f17
@stt-anch
Use tabs.
eb9ea3f
@stt-anch
Tab fixes.
3899635
@andreycha

andreycha commented May 3, 2023

Copy link
Copy Markdown
Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

fluffynuts
fluffynuts approved these changes May 3, 2023
View reviewed changes

@fluffynuts fluffynuts left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I can't make any promises about when this gets out live - I haven't had a lot of time to put into this in a while ): I'm currently formulating a plan to do beta / prerelease packages with less release friction so that perhaps at least things can get out quicker, but I have to speak with more venerable Apache people on what's process would be acceptable.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

andreycha reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@fluffynuts
fluffynuts merged commit 22d3378 into apache:master May 3, 2023
@andreycha

andreycha commented May 3, 2023

Copy link
Copy Markdown
Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andreycha
andreycha deleted the feat/support-peek-in-stacks branch May 3, 2023 13:10
@fluffynuts

fluffynuts commented May 4, 2023

Copy link
Copy Markdown
Contributor

@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 🤷 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" )':

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andreycha

andreycha commented May 6, 2023

Copy link
Copy Markdown
Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@FreeAndNil FreeAndNil added this to the 2.0.16 milestone Mar 5, 2024
@andreycha andreycha mentioned this pull request Apr 2, 2024
log4net layout: log latest scope value elastic/ecs-dotnet#367
Merged
@dependabot dependabot Bot mentioned this pull request Aug 4, 2025
Bump Amazon.Lambda.AspNetCoreServer and 31 others exceptionless/Exceptionless.Net#341
Closed
This was referenced Aug 19, 2025
Bump log4net from 2.0.6 to 2.0.17 nguyen365-org/ghas_net#6
Open
Bump log4net to 2.0.17 AEC-Collection/ObjectTK#1
Open
@dependabot dependabot Bot mentioned this pull request Sep 8, 2025
deps: Bump log4net from 2.0.15 to 2.0.17 1-21Ben/ppgsage50-plugin#6
Open
@dependabot dependabot Bot mentioned this pull request Oct 31, 2025
Bump log4net from 2.0.12 to 3.2.0 testing-felickz/vulnerable-dependencies2#1
Open
This was referenced Nov 11, 2025
Bump log4net from 2.0.12 to 3.2.0 zkcilef/vulnerable-dependencies#1
Open
Bump log4net from 2.0.13 to 3.2.0 MjrTom/CastleCore#2
Merged
Bump log4net from 2.0.12 to 3.2.0 testing-zkcilef/vulnerable-dependenciesB#1
Open
Bump log4net from 2.0.12 to 3.2.0 testing-zkcilef/vulnerable-dependenciesC#1
Open
Bump log4net from 2.0.12 to 3.2.0 testing-zkcilef/vulnerable-dependencies#1
Open
@dependabot dependabot Bot mentioned this pull request Dec 18, 2025
Bump log4net from 2.0.12 to 3.2.0 ksenthilraj/vulnerable-dependencies#1
Open
@dependabot dependabot Bot mentioned this pull request Dec 28, 2025
Bump log4net from 2.0.13 to 3.2.0 MjrTom/CastleCore#13
Merged
This was referenced Jan 7, 2026
deps: Bump the all-dependencies group with 8 updates logzio/logzio-dotnet#82
Closed
deps: Bump the all-dependencies group with 8 updates logzio/logzio-dotnet#84
Closed
This was referenced Jan 27, 2026
Bump log4net from 2.0.13 to 3.2.0 MjrTom/CastleCore#23
Merged
deps: Bump the all-dependencies group with 8 updates logzio/logzio-dotnet#85
Closed
This was referenced Feb 3, 2026
deps: Bump the all-dependencies group with 12 updates logzio/logzio-dotnet#86
Closed
deps: Bump the all-dependencies group with 12 updates logzio/logzio-dotnet#87
Merged
@dependabot dependabot Bot mentioned this pull request Aug 4, 2026
Bump log4net from 2.0.8 to 3.3.0 roblevineco/configgen#12
Open
This was referenced Aug 23, 2026
Bump the nuget group with 1 update MAVProxyUser/MissionPlanner-mac-secured#1
Open
Bump log4net from 2.0.10 to 3.3.0 Logta/TRPGSkillBoard#5
Merged
This was referenced Aug 31, 2026
Bump log4net from 2.0.15 to 3.3.0 ralforion/TDSProxy#3
Closed
Bump log4net from 2.0.13 to 3.3.0 RotorsAndCams/RAC-ProTAR-Planner#6
Open
Bump log4net from 2.0.13 to 3.3.0 RotorsAndCams/RAC-VORBasedNavigation#1
Open
@dependabot dependabot Bot mentioned this pull request Sep 8, 2026
Bump log4net from 2.0.8 to 3.3.0 decentralized-threat-intelligence/vulnerable_net_core#2
Open
This was referenced Sep 19, 2026
Bump log4net from 2.0.10 to 3.3.0 mqamarmunir/Interfacing_All_Applications#14
Merged
Bump log4net from 2.0.10 to 3.3.0 mqamarmunir/Interfacing_All_Applications#15
Open
Bump log4net from 2.0.10 to 3.3.0 elvinyao/Topshelf.Abp.Integrations#8
Open
This was referenced Oct 8, 2026
Bump log4net from 2.0.13 to 3.3.0 SBY-TECH/MissionPlanner-gps-config#2
Open
Bump log4net from 2.0.15 to 3.3.0 octgn/OCTGN#2359
Merged
Bump log4net from 2.0.8 to 3.3.0 METACMETAHA/sap-wialon-fleet-audit#15
Closed
Bump log4net from 2.0.8 to 3.3.0 METACMETAHA/sap-wialon-fleet-audit#19
Closed
This was referenced Oct 21, 2026
Bump the nuget group with 2 updates jonathan-vella/ghpc-appmod-eShop#1
Open
Bump log4net from 2.0.8 to 3.3.0 yuu-eguci/MultiLangApp-old#6
Closed
This was referenced Oct 29, 2026
Bump the nuget group with 1 update rjmurillo/ApplicationInsights-dotnet#17
Open
Bump log4net from 2.0.12 to 3.3.0 rsymo/AzureDevOpsDemoGenerator-terminal#21
Merged
Bump log4net from 2.0.8 to 3.5.0 devsecops-lab-luis/demo-ghas-multilenguaje#12
Closed
Bump log4net from 2.0.8 to 3.3.0 stockmansy/NoeSBot#10
Merged
Bump log4net from 2.0.10 to 3.3.0 snuids/nyx_dotnet_skeleton#4
Open
This was referenced Nov 6, 2026
Bump log4net from 2.0.3 to 3.3.0 ICMA-SERVICES/TSS_Ogun#4
Open
Bump log4net from 2.0.14 to 3.3.0 bigtyre-isaac/CameraStream#2
Closed
Bump log4net from 2.0.15 to 3.6.0 sg-scale/NETworkManager--2022.12.20.0#5
Open
This was referenced Nov 13, 2026
Bump log4net from 2.0.8 to 3.6.0 devsecops-lab-luis/demo-ghas-multilenguaje#27
Open
Bump log4net from 2.0.10 to 3.3.0 CoderAllan/CSharpTools#12
Open
Bump log4net from 2.0.12 to 3.3.0 MohsenMohamad/Ecommerce#48
Merged
This was referenced Nov 24, 2026
Bump log4net from 2.0.8 to 3.3.0 Unity-Technologies/logzio-dotnet#2
Open
Bump log4net from 2.0.13 to 3.3.0 Unity-Technologies/CastleCore#1
Open
Bump log4net from 2.0.10 to 3.3.0 Martinii89/Unreal-Library#13
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@fluffynuts fluffynuts fluffynuts approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

2.0.16

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@andreycha @fluffynuts @FreeAndNil @stt-anch
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.