I've migrated to Enterprise Library 6 with semantic logging. It works fine with in process logging, but I could not get out-of-process logging working. SemanticLogging SVC is started as Windows Service, and I know it's working fine because I could not delete the logfile configured due to error 'File in use by Semantic-SVC Service'. Additionally it recreates a new file if I change the filename in SemanticLogging-svc.xml. But the logfile is just empty. I'm using the examples from https://msdn.microsoft.com/en-us/library/dn440729%28v=pandp.60%29.aspx . I call MyCompanyEvents.Log.Startup. MatchAnyKeyword is set to 12, Level is 'always' so it should log the Startup message. Any ideas?
[EventSource(Name = "MyCompany")]
public class MyCompanyEventSource : EventSource
{
public class Keywords
{
public const EventKeywords Page = (EventKeywords)1;
public const EventKeywords DataBase = (EventKeywords)2;
public const EventKeywords Diagnostic = (EventKeywords)4;
public const EventKeywords Perf = (EventKeywords)8;
}
public class Tasks
{
public const EventTask Page = (EventTask)1;
public const EventTask DBQuery = (EventTask)2;
}
private static MyCompanyEventSource _log = new MyCompanyEventSource();
private MyCompanyEventSource() { }
public static MyCompanyEventSource Log { get { return _log; } }
[Event(1, Message = "Application Failure: {0}",
Level = EventLevel.Critical, Keywords = Keywords.Diagnostic)]
internal void Failure(string message)
{
this.WriteEvent(1, message);
}
[Event(2, Message = "Starting up.", Keywords = Keywords.Perf,
Level = EventLevel.Informational)]
internal void Startup()
{
this.WriteEvent(2);
}
[Event(3, Message = "loading page {1} activityID={0}",
Opcode = EventOpcode.Start,
Task = Tasks.Page, Keywords = Keywords.Page,
Level = EventLevel.Informational)]
internal void PageStart(int ID, string url)
{
if (this.IsEnabled()) this.WriteEvent(3, ID, url);
}
...
}
<?xml version="1.0"?>
<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">
<!-- Optional settings for this host -->
<traceEventService/>
<!-- Event sink definitions used by this host to
listen ETW events emitted by these EventSource instances -->
<sinks>
<consoleSink name="ConsoleEventSink">
<sources>
<eventSource name="MyCompany" level="LogAlways" matchAnyKeyword="12"/>
</sources>
<eventTextFormatter header="+=========================================+"/>
</consoleSink>
<rollingFlatFileSink name="RollingFlatFileSink"
fileName="c:\\logs\\RollingFlatFile.log"
timeStampPattern="yyyy"
rollFileExistsBehavior="Overwrite"
rollInterval="Day">
<sources>
<eventSource name="MyCompany"
level="LogAlways" matchAnyKeyword="12"/>
</sources>
</rollingFlatFileSink>