EventSource / Enterprise Library Logging caches remote methods (perhaps in the tool manifest!)

Short version

If I change this ...

EventSource(Name="BasicLogger") public class BasicLogger : EventSource { ... } 

to that...

 EventSource(Name="HardymanDatabaseLog") public class BasicLogger : EventSource { ... } 

... I still get log messages, but they are corrupted.

Either the messages do not arrive, or they are formatted using the absence / delete / delete method, which does not even exist in my current project!


For some unknown reason, there is a problem with the specific string "HardymanDatabaseLog"

I think that this may be before the spoiled instrumental manifest, which appears somewhere.

Read on to find out more ...! (thanks: o))


Long version (with images)

I have a simple console application that references EnterpriseLibrary.SemanticLogging through the nuget package.

Using the sample code from here , I added the BasicLogger class.

When I run my simple application ...

 using System.ComponentModel; using System.Diagnostics.Tracing; namespace Etw { class Program { static void Main(string[] args) { BasicLogger.Log.Error("Hello1"); BasicLogger.Log.Critical("Hello2"); } } [EventSource(Name = "BasicLogger")] public class BasicLogger : EventSource { public static readonly BasicLogger Log = new BasicLogger(); [Event(1, Message = "{0}", Level = EventLevel.Critical)] public void Critical(string message) { if (IsEnabled()) WriteEvent(1, message); } [Event(2, Message = "{0}", Level = EventLevel.Error)] public void Error(string message) { if (IsEnabled()) WriteEvent(2, message); } [Event(3, Message = "{0}", Level = EventLevel.Warning)] public void Warning(string message) { if (IsEnabled()) WriteEvent(3, message); } [Event(4, Message = "{0}", Level = EventLevel.Informational)] public void Informational(string message) { if (IsEnabled()) WriteEvent(4, message); } } } 

... I get the following response in the log viewer console ( SemanticLogging-svc.exe )

Good magazine

... what is right!

BUT , if now I am updating the EventSource attribute to [EventSource(Name = "HardymanDatabaseLog")] and setting up SemanticLogging-svc.xml also the HardymanDatabaseLog link ...

 <?xml version="1.0" encoding="utf-8" ?> <configuration xmlns="http://schemas.microsoft.com/practices/2013/entlib/semanticlogging/etw" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.microsoft.com/practices/2013/entlib/semanticlogging/etw SemanticLogging-svc.xsd"> <sinks> <consoleSink name="ConsoleEventSink"> <sources> <eventSource name="HardymanDatabaseLog" level="LogAlways" /> </sources> <eventTextFormatter header="+=========================================+"/> </consoleSink> </sinks> </configuration> 

... then I get the following response in the log viewer console ...

Bad log

... who not only lost the first message, but also ruined the second!

If you look closely at the line starting with EventId : 1 , you will see that it says Message : Application Started ... How, why and where does this message come from ?! ... even the Level : Informational bit is incorrect ... my code has Level = Critical !

Before this problem started, I created a method (long since deleted) in the BasicLogger class that had the attribute [Event(1, Message = "Application Started.", Level = EventLevel.Informational)] , and now when I set the EventSource(Name="HardymanDatabaseLog") , this phantom method is called.

To be clear ... the text "Application is running" no longer exists in my application (I'm using a completely new project) ... The only reason for this error is to reuse 'HardymanDatabaseLog' the name of the event source.


Here is what I have done so far to try to clear any corrupted information, will make everything ruin:

  • Rebooted the computer (standard!)
  • Delete and re-add all links to the corporate library (the problem persists between different solutions, so it cannot be an application / solution level setting)
  • Stop and remove perfmon> Data Collector Sets> Event Tracing Sessions> Microsoft-SemanticLogging-Etw-ConsoleEventSink
  • Search for HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog to find out if my application is registered (of course, "HardymanDatabaseLog" was not found anywhere in the registry).
  • Sleep on it
  • System.Diagnostics.EventLog.DeleteEventSource ("HardymanDatabaseLog")
  • Clean / Restore / Clean / Build / Clean / etc / etc.
  • Running my application without visual studio host application

And here is what I tried, but did not succeed with ...

  • Determine if configuration data is saved to the Enterprise Library.
  • Determine if .NET EventSource saves configuration data
  • Reinstall the corporate library (only install-packages.ps1 included in the download )
  • Head tilt on keyboard

All thanks and suggestions are greatly appreciated.


Update

Using JustDecompile, I found a method in the EventSource code that uses an object named ManifestBuilder . This method seems to create a <instrumentationManifest /> document, which, of course, can contain all the information that seems to be hidden in the phantom method.

Perhaps someone can shed light on where these magical documents are stored in the context of .NET and the corporate library?


Update 2

As @Randy Levy observed when examining the source of SLAB, the problem can be fixed by deleting files in C:\Users\<UserName>\AppData\Local\Temp\7D2611AE-6432-4639-8B91-3E46EB56CADF . His answer also relates to this question ... SLAB, outside the process: changing the signature of the event source method causes the event logging to be incorrect .

Thanks @Randy Levy!

+7
c # enterprise-library etw-eventsource semantic-logging
source share
2 answers

This certainly sounds like some sort of cache issue manifest and / or corruption.

For a console application, SLAB ETW Service caches manifests in the C: \ Users \\ AppData \ Local \ Temp \ 7D2611AE-6432-4639-8B91-3E46EB56CADF folder. If there is a problem with manifest caching, then deleting the manifest .xml files (in this case BasicLogger.manifest.xml and HardymanDatabaseLog.manifest.xml) in this directory should (hopefully) solve the problem.

These steps are to stop the service, delete the XML files, and restart the service.

+6
source share

Make sure that you check the user profile under which your service operates. Therefore, if your Enterpise semantic logging service is running in LocalService or NetworkService, the path will not be c: \ users ...

The path in this case will be

C: \ Windows \ ServiceProfiles \ LocalService \ AppData \ Local \ Temp \ 7D2611AE-6432-4639-8B91-3E46EB56CADF

or

C: \ Windows \ ServiceProfiles \ NetworkService \ AppData \ Local \ Temp \ 7D2611AE-6432-4639-8B91-3E46EB56CADF

0
source share

All Articles