I have all of my service logic encapsulated in class library. When I instantiate the class library in a command line app I receive my trace information.
When I instantiate the class in a Windows Service, I see that my Custom trace listener has created the logs directory and start a file, but it stays a 0 KB.
Both applications have this in the .config:
<system.diagnostics>
<switches>
<add name="PTraceSwitch" value="Verbose" />
</switches>
<trace autoflush="true">
<listeners>
<add name="CustomXmlWriterTraceListener" />
<add name="MyServiceEventListener" />
<remove name="Default" />
</listeners>
</trace>
<sharedListeners>
<add
type="CustomUtilities.CustomXmlWriterTraceListener, CustomUtilities"
name="CustomXmlWriterTraceListener"
initializeData="Logs\MyService.svclog"
RollLogAtMidnight="True"
DateFormat="yyyy.MM.dd"
MaxFileSizeMB="1"
CompressLogsOlderThanTimeSpan="1.00:0:00"
DeleteLogsOlderThanTimeSpan="30.00:00:00"/>
<add name="MyServiceEventListener"
type="System.Diagnostics.EventLogTraceListener"
initializeData="MyServiceEventLog">
<filter type="System.Diagnostics.EventTypeFilter"
initializeData="Warning" />
</add>
</sharedListeners>