ASP.NET/WCF tracing does not work within Sharepoint - wcf

I configured message tracing for my WCF webservice like this:
<!--TRACING -->
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Verbose, ActivityTracing" propagateActivity="true">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
<listeners>
<add name="xml" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="log_messages_verbose.log" />
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
This works fine on my development machine, it logs all messages and traces to an xml file.
Now when deploying the webservice as (sub) Webapplication inside a Sharepoint Webapplication, the service works fine but the trace file stays empty.
I checked the permission on the file, tried absolute file paths, but it still does not work.
Because the webservice is deployed as sub webapplication, it inherits the web.config settings from sharepoint. Could this be an issue? Does sharepoint somehow disable the normal tracing?
Any suggestions are welcome..

Assuming your web service is deployed to its own directory (so that it does not interfere with SharePoint), have you tried adding a web.config with the above trace config to that directory?
Otherwise as Shiraz suggests try adding the trace code to SharePoint's web.config.

I had the same issue. What worked for me was to use the "SvcConfigEditor.exe" tool on the SharePoint web.config. I probably did something wrong trying to do it without the tool. C:\inetpub\wwwroot\wss\VirtualDirectories\.

Do you have the possibility of copying this into sharepoint's web.config?
Also check in your event log for error messages.
Edit
Not sure what the default is for enabled, you could try setting it to true
<trace enabled="true" />

I had the same problem, then moved the section to the root web.config in C:\inetpub\wwwroot\wss\VirtualDirectories\80.
I had the same issue with log4net not working, and again moved it into the parent web.config file.
Both now work.

Related

WCF Trace for single URL

We have a WCF-based backend API implementation. We are dealing with a production problem, and we need to investigate just a single service erroneous behavior.
We need to get WCF Trace logs, but since the system is heavily stressed, we expect that activation for the whole application cannot be done.
What we need is to enable WCF tracing for selectively chosen URL (a single service).
We tried with the location element - to get the configuration applied only for particular folder/file.svc, but this does not work. Still we had to enable WCF Tracing for the whole IIS Application to get the traces generated.
Any idea how to enable WCF Tracing for a single service ?
WCF tracing is built on top of System.Diagnostics. You should define trace sources in the configuration file or in code for using trace like this:
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
Also you can refer to this docs for further info.

SignalR Scaleout with Redis

http://www.asp.net/signalr/overview/signalr-20/performance-and-scaling/scaleout-with-redis
I followed this link to scaleout my simple signalr chat visual studio project.
I made my ubuntu virtual mchine on azure which runs redis.
I added GlobalHost.DependencyResolver.UseRedis("server", port, "password", "AppName"); to my startup class and right now I am only testing it on my machine , not other servers.
But it does not work.
As soon as I put in that line my chat program gets stuck at line 1(see below) and never reaches line 2.
1)$.connection.hub.start().done(function () {
2) $('#sendmessage').click(function () {
What am I doing wrong?
It's best to setup server and client-side logging. This page details it http://www.asp.net/signalr/overview/signalr-20/performance-and-scaling/scaleout-in-signalr.
Let us know you're results and maybe we can help...
So after 2 months someone asked for more detail... so here's it copied and pasted
Enabling Tracing For SignalR Scaleout
To enable tracing for the backplanes, add the following sections to the web.config file, under the root configuration element:
<configuration>
<system.diagnostics>
<sources>
<source name="SignalR.SqlMessageBus">
<listeners>
<add name="SignalR-Bus" />
</listeners>
</source>
<source name="SignalR.ServiceBusMessageBus">
<listeners>
<add name="SignalR-Bus" />
</listeners>
</source>
<source name="SignalR.ScaleoutMessageBus">
<listeners>
<add name="SignalR-Bus" />
</listeners>
</source>
</sources>
<switches>
<add name="SignalRSwitch" value="Verbose" />
<!-- Off, Critical, Error, Warning, Information, Verbose -->
</switches>
<sharedListeners>
<add name="SignalR-Bus"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="bus.log.txt" />
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
. . .
</configuration>
You need to enable pub/sub channel on redis server.
Steps:
Open redis.windows.conf file
Go to the Event notification section
Add or uncomment notify-keyspace-events E
Restart redis server.

WCF Tracing switchvalue is Off yet there is still a trace output being generated

After having turned on WCF Tracing to assist with finding a problem, I now wish to turn off tracing. So I have changed my config file to this...
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Off" >
<!-- Information,ActivityTracing-->
<listeners>
<add name="xmlTraceListener" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Off" >
<listeners>
<add name="xmlTraceListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xmlTraceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="C:\WCFLogs\DataPortalTrace.svclog" />
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
Yet there is still trace output being send to the indicated output file. Why is that? What am I missing?
switchValue="Off" will only control System.ServiceModel. It does not control the System.ServiceModel.MessageLogging
As of my knowledge you can control via maxMessagesToLog="0" – you might have already <diagnostics> tag under <system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="0"
/>
</diagnostics>
.NET framework for Configuring Message Logging
The logging level, as well as the additional options, are discussed in the Logging Level and Options section.
The switchValue attribute of a source is only valid for tracing. If you specify a switchValue attribute for the System.ServiceModel.MessageLogging trace source as follows, it has no effect.
Copy
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
If you want to disable the trace source, you should use the logMessagesAtServiceLevel, logMalformedMessages, and logMessagesAtTransportLevel attributes of the messageLogging element instead. You should set all these attributes to false. This can be done by using the configuration file in the previous code example, through the Configuration Editor UI interface, or using WMI. For more information about the Configuration Editor tool, see Configuration Editor Tool (SvcConfigEditor.exe). For more information about WMI, see Using Windows Management Instrumentation for Diagnostics.

wcf message logging uploading files

I'm sending files from clients to a server using WCF with different bindings. I need to know the sizes of the packets that the client send. How should I configure diagnostics in the config?? Or how can I view this?? Thanks.
To enable diagnostics, edit .config file
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="App_Data\WCF.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
Then you can open .svclog file with Microsoft Service Trace Viewer
See also:
Configuring Tracing at MSDN
Administration and Diagnostics at MSDN
Configuring Message Logging at MSDN

How to turn on WCF tracing?

Update:
I have been trying to turn on WCF tracing, but still no success... Below is my lastest update.
Do I need a permission to write to the below location?
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "#\\myservername\folder1\traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
I am using .NET Framework 3.5.
What is the step-by-step instruction to turn on the WCF tracking for debugging purposes?
The following configuration taken from MSDN can be applied to enable tracing on your WCF service.
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true" >
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="myUserTraceSource"
switchValue="Information, ActivityTracing">
<listeners>
<add name="xml"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="Error.svclog" />
</sharedListeners>
</system.diagnostics>
</configuration>
To view the log file, you can use "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\SvcTraceViewer.exe".
If "SvcTraceViewer.exe" is not on your system, you can download it from the "Microsoft Windows SDK for Windows 7 and .NET Framework 4" package here:
Windows SDK Download
You don't have to install the entire thing, just the ".NET Development / Tools" part.
When/if it bombs out during installation with a non-sensical error, Petopas' answer to Windows 7 SDK Installation Failure solved my issue.
In your web.config (on the server) add
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\logs\Traces.svclog"/>
</listeners>
</source>
</sources>
</system.diagnostics>
Go to your Microsoft SDKs directory. A path like this:
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools
Open the WCF Configuration Editor (Microsoft Service Configuration Editor) from that directory:
SvcConfigEditor.exe
(another option to open this tool is by navigating in Visual Studio 2017 to "Tools" > "WCF Service Configuration Editor")
Open your .config file or create a new one using the editor and navigate to Diagnostics.
There you can click the "Enable MessageLogging".
More info: https://msdn.microsoft.com/en-us/library/ms732009(v=vs.110).aspx
With the trace viewer from the same directory you can open the trace log files:
SvcTraceViewer.exe
You can also enable tracing using WMI. More info:
https://msdn.microsoft.com/en-us/library/ms730064(v=vs.110).aspx
Instead of you manual adding the tracing enabling bit into web.config you can also try using the WCF configuration editor which comes with VS SDK to enable tracing
https://stackoverflow.com/a/16715631/2218571