Out-of-process logger stops logging when level is changed

Topics: Semantic Logging Application Block
Jul 15, 2014 at 2:27 PM
Edited Jul 15, 2014 at 2:50 PM
I’ve developed a system that utilizes rollingFlatFileSink (rollFileExistsBehavior="Overwrite") and jsonEventTextFormatter. Initially I set level to “Warning” and execute “SemanticLogging-svc.exe -c”; this collects all events with level=”Warning” with no problem.

Next, I open configuration file with Notepad and change level to “Informational”. The console displays a message to the effect that “A sink was updated from configuration changes” and the logger continues to record with no problem; this time it would record Warnings and Informationals.

Problem arises after I restart the logger by pressing “Enter”, then running “SemanticLogging-svc.exe -c” again. No events of any level are being recorded. It usually takes few restarts of my software and out-of-process logger to resume recording.

Any reason for this? What am I doing wrong? Please help.

Thank you,

Eugene
Jul 17, 2014 at 7:22 AM
I wasn't able to reproduce your issue. It sounds like perhaps there is some issue with ETW Sessions not being closed/opened but it's hard to tell from the description.

Is it possible to provide a sample project with the steps to reproduce the issue? You can send to my email or upload to OneDrive.

Thanks,

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Jul 17, 2014 at 3:35 PM
Hi Randy,

Thank you for your offer to help me out. I have e-mailed you my test harness renamed to .renameMe so please rename it back to .zip. There is still a chance e-mail security will block my message so I duplicate it on this forum; let me know if you did not receive my e-mail message.

To reproduce:
  • Build and launch “ETWTester.exe” (build output to the “Bin\Debug” folder) followed by “SemanticLogging-svc.exe –c” (found in the “Service” folder)
  • As you will see the initial level is set to “Warning”. Pressing “Critical Message”, “Error Message”, and “Warning Message” buttons will write to the log while pressing “Informational Message” won’t (as expected).
  • Without stopping “SemanticLogging-svc.exe” change level to “Informational”; you should see all four buttons write to the log (as expected).
  • Re-start “SemanticLogging-svc.exe”, try pressing any button on the workbench; nothing will be logged until you re-start “ETWTester.exe” (sometimes more than once).
Thank you,

Eugene
Jul 22, 2014 at 7:51 AM
Edited Jul 22, 2014 at 7:51 AM
Thanks for a good repro scenario.

I was able to recreate the issue with the sample application. I notice that you are using Microsoft.Diagnostics.Tracing.EventSource. When I switched to using System.Diagnostics.Tracing.EventSource the issue did not occur.

Is there a reason you need to use Microsoft.Diagnostics.Tracing.EventSource? If so, then you will need to compile SLAB against Microsoft.Diagnostics.Tracing.EventSource and go with a custom build.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Marked as answer by yevglerner on 7/22/2014 at 1:27 PM
Jul 22, 2014 at 9:27 PM
Reason I'm using Microsoft.Diagnostics.Tracing.EventSource is that initially, the NuGet package installer set my project to reference this library. Package description states that "... it provides newer version that has more features. It is meant to be used as stop gap until those features ported to System.Diagnostics.Tracing.EventSource"

I guess one of those features is "Channel" property of the "EventAttribute." I'm using it in few places so I globally searched for "using System.Diagnostics.Tracing;" and replaced it with "using Microsoft.Diagnostics.Tracing;", updated NuGet packages (this added reference to "Microsoft.Diagnostics.Tracing" to all projects), then re-compiled SLAB. Unfortunately, even after that the problem persisted.

It turns out the logging accurately resumes after restarting of my application, so I think I could live with this problem. Strangely, the logging also resumed after I had launched PerfView instead of re-starting my app.

If there is anything you can recommend, please do.

Thank you,

Eugene
Aug 15, 2014 at 9:45 PM
I seem to be having the same problem. I have a long-running app (a Web API as it happens) that I've added db logging to via the out-of-process service. Start the service, start the app, everything is fine and logging works. However, if I alter the configuration, which according to the event listener drops/adds the sink, or if I stop/start the service, the app does not log anymore. Exit and restart the app, and it logs again. So it appears that the service must be running at app start, and continue running unchanged during the life of the logging app, in order for logging to work.

I'm using the current stable nuget package for the out-of-process service; the event source the app uses extends System.Diagnostics.Tracing.

Is there something I'm missing? It doesn't seem like it should behave this way.

Ed