WCF Trace logging appears to not be working in one of my wcf windows services. I've used this same configuration in other services and it has worked in the past. I'm stumped at this point. Here is the configuration that I have:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging"
switchValue="Information, ActivityTracing">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="C:\ProgramData\Bastian Software\Logs\ExactaManifest\Messages.svclog" />
</listeners>
</source>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="C:\ProgramData\Bastian Software\Logs\ExactaManifest\WCF.svclog" />
</listeners>
</source>
</sources>
<trace autoflush="true" />
</system.diagnostics>
<system.serviceModel>
<diagnostics performanceCounters="All">
<messageLogging
logMessagesAtTransportLevel="true"
logMessagesAtServiceLevel="false"
logMalformedMessages="true"
logEntireMessage="true"
maxSizeOfMessageToLog="2147483647" maxMessagesToLog="25000" />
</diagnostics>
</system.serviceModel>
</configuration>
It doesn't appear to be a permissions issue because I manually created a folder and file with the same user that the service is running under. Also I do see the following in the event viewer related to this wcf trace logging:
Any suggestions?
Viewing Event Logs. Event logging is enabled automatically by default, and there is no mechanism to disable it. Events logged by WCF can be viewed using the Event Viewer. To launch this tool, click Start, click Control Panel, double-click Administrative Tools, and then double-click Event Viewer.
To set up, build, and run the sample Before running the Tracing and Message Logging sample, create the directory C:\logs\ for the service to write the . svclog files to. The name of this directory is defined in the configuration file as the path for the traces and messages to be logged and can be changed.
To activate message logging, you must add a trace listener to the System. ServiceModel. MessageLogging trace source and set attributes for the <messagelogging> element in the configuration file. The following example shows how to enable logging and specify additional options.
The log files will only be created if the directory specified in the configuration previously exists; it's more than just the permissions being in place to create the log file. See this note section from MSDN article:
Trace files are not created without initially creating the log directory. Make sure that the directory C:\logs\ exists, or specify an alternate logging directory in the listener configuration.
Based on your comment "it does not generate any svclogs" leads me to believe the issue is related to your permissions. If you are utilizing Windows 8 Visual Studio will need to be opened as an Administrator. If you don't, then it will not generate any trace log files.
Some other items you might check:
I'm assuming it is either hosted through Internet Information System (IIS) or being debugged through Visual Studio. One of those two should hopefully resolve the issue.
On Microsoft's Developer Network they actually add an important note about running as an Administrator in Windows 8 due to how often it is overlooked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With