Skip to content

Ensure TraceLogger log level is maintained property#745

Open
Youssef1313 wants to merge 2 commits intocastleproject:masterfrom
Youssef1313:loglevel
Open

Ensure TraceLogger log level is maintained property#745
Youssef1313 wants to merge 2 commits intocastleproject:masterfrom
Youssef1313:loglevel

Conversation

@Youssef1313
Copy link
Copy Markdown

@Youssef1313 Youssef1313 commented May 2, 2026

The added test would fail only under .NET Framework without the production change in this PR.

Under .NET Framework, if you execute the following:

new TraceSource("Default", SourceLevels.Warning).Switch.Level

it will produce -1 (corresponding to SourceLevels.All).

After Initialize gets called in TraceLogger constructor, the level is set as:

Level = MapLoggerLevel(traceSource.Switch.Level);

which used to set it to Trace, even when Warning is explicitly requested.

The caching in TraceLogger generally looks wrong to me though. It caches TraceSource per Name, not taking into account the fact that multiple TraceLogger might be requested with the same name but different levels.

@stakx
Copy link
Copy Markdown
Member

stakx commented May 2, 2026

To be honest, I'm not sure there's much sense in investing any more time and work in Castle logging facilities. Seems more likely to me that we're going to deprecate them soon (see the discussion in #408, plus Jono mentioned to me recently that Windsor hasn't seen much activity in recent times... so one fewer reason for keeping logging facilities going).

@Youssef1313
Copy link
Copy Markdown
Author

@stakx Any expected time when they will be deprecated? And when 6.x is expected to be released?

Meanwhile, this bug is causing perf issues for Moq under .NET Framework. I think the scope of the change is small enough and should be safe to get in until the deprecation happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants