Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Service: How to find server logs to understand error?

Tags:

c#

wcf

I know this is probably a pretty basic question but I am brand new to WCF and Service creation. I am running a local hosted WCF service using Microsoft VS 2010 C#4. I am trying to run the service through the URL through simple binding and running the PUT and GET methods through the URL. I am getting the:

. See server logs for more details.

error when I try to make a service request. How can I find these server logs?

like image 726
ford prefect Avatar asked Aug 29 '13 13:08

ford prefect


People also ask

How do I check WCF logs?

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.

How do I enable tracing and message logging in WCF?

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.

What is WCF trace file?

WCF defines a trace source for each assembly. Traces generated within an assembly are accessed by the listeners defined for that source. The following trace sources are defined: System.


2 Answers

Logging is not necessarily turned on. Tracing and logging need to be enabled in WCF configuration (app.config or web.config). You can do this manually, or by clicking app.config and then selecting Edit WCF Configuration. If this item doesnt appear in context menu (happens in old versions of VS), you can find it in VS Tools menu or by running it manually (SvcConfigEditor.exe).

By default, messages are logged to files in directory from which application is ran. You can edit this in configuration editor once you enable logging. Editor will allow you to specify file path once you enable logging or tracing.

WCF Configuration Editor

You can later use Microsoft Service Trace Viewer tool for going through the files, as large XMLs and are not user friendly. Viewer tool should come up itself once you double click log files, or you can run it manually (SvcTraceViewer.exe).

enter image description here

like image 133
Nikola Radosavljević Avatar answered Sep 24 '22 06:09

Nikola Radosavljević


Add this to your web.config. you specify where the log goes in the initializeData attribute of the tracelistener

<system.serviceModel>
    <diagnostics>
        <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
    </diagnostics>
</system.serviceModel>
<system.diagnostics>
    <sources>
        <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
            <listeners>
                <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\Temp\SvcLog\Traces.svclog" />
            </listeners>
        </source>
    </sources>
</system.diagnostics>
like image 35
usha Avatar answered Sep 25 '22 06:09

usha