-
Notifications
You must be signed in to change notification settings - Fork 11
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
Each trace record includes an extra message: <program name> <trace level> # #20
Comments
There is some overlap between the two (on .NET at least, I can't recall offhand if .NETCore is the same) - the Microsoft documentation at https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.debug.listeners?view=netframework-4.8#remarks states that the Trace and Debug classes share a single listeners collection, so adding a listener to one also adds it to the other. |
Per the TraceSource.TraceEvent method documentation, an override of the TraceSource.TraceEvent method could construct the message w/o the default output prefix: "The trace content is listener specific. If the method is not overridden by the listener implementation, the default output is the name of the trace source, its numeric identity, and the event type. Additional trace content is dependent upon the listener's TraceOutputOptions property value." However, looking at the code of the trace listener (https://referencesource.microsoft.com/#System/compmod/system/diagnostics/TraceListener.cs,8b8ba5341c6d1740), a header is emitted by the trace listener:
` |
Serilog Sinks Trace works like a charm but seems to added an extra record before each log message. Is there a way to control this behavior?
To demonstrate, I am showing below the Console log messages (each tagged with a
c::
) and the Trace messages (each tagged with at::
). The trace messages where stored in a queue, which is dumped for testing purposes.Here is the Console trace messages:
`
c::20:46:08.731 -08:00, [INF], (isr.Core.Logging.Tester.Program), Starting application...
c::20:46:08.759 -08:00, [INF], (isr.Core.Logging.Tester.App), Running application.
c::20:46:08.803 -08:00, [INF], (isr.Core.Logging.Tester.App), Logging into C:\My\Libraries\VS\Core\Core5\src\Testers\Logging\bin\Debug_Logs\lime_20210210.log.
c::20:46:08.810 -08:00, [DBG], (isr.Core.Logging.Tester.TestService), Running logging service.
c::20:46:08.817 -08:00, [DBG], (isr.Core.Logging.Tester.TestService), Throwing divide by zero exception.
c::20:46:08.835 -08:00, [ERR], (isr.Core.Logging.Tester.App), reporting exception
System.InvalidOperationException: Caught in App
---> System.DivideByZeroException: Attempted to divide by zero.
at isr.Core.Logging.Tester.TestService.Run() in C:\My\Libraries\VS\Core\Core5\src\Testers\Logging\Program\Program.cs:line 309
at isr.Core.Logging.Tester.App.Run() in C:\My\Libraries\VS\Core\Core5\src\Testers\Logging\Program\Program.cs:line 249
--- End of inner exception stack trace ---
`
And here are the trace messages where each line is preceded by the name of the program (
LoggingTester
) , the trace level (e.g.,information
) and a zero.`
--- Queue Trace Listener Records after flush:
LoggingTester Information: 0 :
t::20:40:22.955 -08:00, [INF], (isr.Core.Logging.Tester.Program), Starting application...
LoggingTester Information: 0 :
t::20:40:22.979 -08:00, [INF], (isr.Core.Logging.Tester.App), Running application.
LoggingTester Information: 0 :
t::20:40:23.024 -08:00, [INF], (isr.Core.Logging.Tester.App), Logging into C:\My\Libraries\VS\Core\Core5\src\Testers\Logging\bin\Debug_Logs\lime_20210210.log.
t::20:40:23.031 -08:00, [DBG], (isr.Core.Logging.Tester.TestService), Running logging service.
t::20:40:23.035 -08:00, [DBG], (isr.Core.Logging.Tester.TestService), Throwing divide by zero exception.
LoggingTester Error: 0 :
t::20:40:23.052 -08:00, [ERR], (isr.Core.Logging.Tester.App), reporting exception
System.InvalidOperationException: Caught in App
---> System.DivideByZeroException: Attempted to divide by zero.
at isr.Core.Logging.Tester.TestService.Run() in C:\My\Libraries\VS\Core\Core5\src\Testers\Logging\Program\Program.cs:line 309
at isr.Core.Logging.Tester.App.Run() in C:\My\Libraries\VS\Core\Core5\src\Testers\Logging\Program\Program.cs:line 249
--- End of inner exception stack trace ---
--- End of Queue Trace Listener Records
`
The text was updated successfully, but these errors were encountered: