tags:

views:

202

answers:

3

I have a WCF service (hosted by IIS webpage) that is working but I want to write more info out to a log file.

I inherited code and it had some simple logging to a file. That worked on the original developers machine but I don't get anything written out. Note it reads the log file path from the config which I assume was the web config but just in case I hard coded the location for now "c:\temp\logfile.log".

I gave full permissions to temp to ASPNET and then USERS thinking it was a permissions issues.

Also I noticed there was Tracing and Message logging built into WCF. Tried that but not sure if I'm doing it correctly.

Any ideas about the simple file writing?
Should I be doing the built in logging and if so any simple examples?

Thanks!

A: 

Use the EventViewer logging instead, but you will have to make sure your installer can create the appropriate EventViewer source.

Chris O
A: 

Maybe you should use that Configuration Editor-Tool "SvcConfigEditor.exe" (see description on MSDN). This allows to configure WCF-logging in a quiet easy and structured way.

The log files can then be analysed with the Service Trace Viewer-Tool "SvcTraceViewer.exe" (see on MSDN).

Both tools are bundled with Visual Studio an can be downloaded from Microsoft.

Sebastian Seifert
+2  A: 

To configure Logging: Configure Logging
1. In the Configuration Editor, select the Diagnostics node.

2. In the right pane, click Enable MessageLogging.

This will create ServiceModelMessageLoggingListener and System.ServiceModel.MessageLogging nodes under the Listeners and Sources folders, respectively.

3. In the left pane, select MessageLogging under the Diagnostics node.

4. Set the LogMessagesAtServiceLevel attribute to True by choosing this option from the drop-down list.

5. In the left pane, select ServiceModelMessageLoggingListener under the Listeners node.

Note the default value of the InitData attribute, which is set to c:\inetpub\wwwroot\WCFService\web_messages.svclog, the location where the message will be logged.

via WCF Security Guidance.

RandomNoob