seq-client-log4net icon indicating copy to clipboard operation
seq-client-log4net copied to clipboard

improvement: remove key sanitization

Open vmandic opened this issue 2 years ago • 3 comments

Hi, I have a log4net context propety like 'X-SomeName-Something', it gets pushed to SEQ with SeqAppender but in SEQ it appears in properties with a different name, ie. without the dashes like XSomeNameSomething? Is this by design or a bug, is there a way I can force this to go as intented with dashes so I can query @Properties["X-SomeName-Something"] = 'lorem12345'

I use this within a .NET48 MVC webapp on Log4Net 2.0.14, the SeqAppender is <package id="Seq.Client.Log4Net" version="3.1.0" targetFramework="net48" /> and I async buffer it with <appender name="SeqAsyncForwarder" type="Easy.Logger.AsyncBufferingForwardingAppender, Easy.Logger">.

Problematic code sample:


// inside Global.asax > private void App_BeginRequest(object sender, EventArgs e) { ... }

var correlationid = Guid.NewGuid().ToString();
LogicalThreadContext.Properties["X-Some-CorrelationId"] = correlationid;
ThreadContext.Properties["X-Some-CorrelationId"] = correlationid;

Shows up in SEQ log as: image

So its missing the two dashes in the property name. Any ideas, is this related to this lib? Thanks.

EDIT

I am looking at: https://github.com/datalust/seq-client-log4net/blob/dev/src/Seq.Client.Log4Net/Client/Log4Net/LoggingEventFormatter.cs and I guess it might be to some code in it?

vmandic avatar Mar 25 '22 18:03 vmandic

OK I found the issue it is this line in function SanetizeKey: https://github.com/datalust/seq-client-log4net/blob/a60ddeb9b7a545248c7da7e315b399b51927d3bb/src/Seq.Client.Log4Net/Client/Log4Net/LoggingEventFormatter.cs#L102

I will probably be opening an improvement PR to allow the '-' dash symbol.

vmandic avatar Mar 25 '22 18:03 vmandic

That's great, thank you, @vmandic 👍

nblumhardt avatar Mar 25 '22 21:03 nblumhardt

Hi @nblumhardt, hope this is OK now.

vmandic avatar Mar 28 '22 16:03 vmandic