Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown in Adapter when calling IEnumerable.Reset() #96

Open
thabondlovuda opened this issue Nov 15, 2019 · 2 comments
Open

Exception thrown in Adapter when calling IEnumerable.Reset() #96

thabondlovuda opened this issue Nov 15, 2019 · 2 comments

Comments

@thabondlovuda
Copy link

thabondlovuda commented Nov 15, 2019

GetRenderedFormat(object message, string stringRepresentationOfNull = "") in Tracer.Log4net/Adapters/LoggerAdapter.cs calls enumerable.Reset(), this method might throw a notSupported or notImplemented Exception as per

https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerator.reset?view=netframework-4.8

As a workaround I tried the setting "LogUseSafeParameterRendering" but I noticed this:
var config = Environment.GetEnvironmentVariable("LogUseSafeParameterRendering");

I don't think GetEnvironmentVariable looks at the app config at all as per the version history

@csnemes
Copy link
Owner

csnemes commented Dec 7, 2019

When an enumerated value is logged you have to call the reset to set it back to start so that the real code can enumerate it. Logging enumerated value is unsafe in the sense that you cannot check in advance if the enumerator can be used twice and if it returns the same values for the two calls. Not logging IEnumerables at all is a big price to pay for some edge cases, so - as you already found in the code - one can use the LogUseSafeParameterRendering flag. I cannot read it from app config as the adapter is netstandard. In hindsight it would've been better to enable turning off parameter logging on a per parameter level (like using NoTrace on a parameter).

@Jovar
Copy link

Jovar commented May 13, 2021

Couldn't your netclassicweaver use ConfigurationManager.AppSettings?

I wound up having to read from my config file, then create an environment variable (in my global.asax.cs), which feels like a hack.

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

No branches or pull requests

3 participants