I have a created a SharePoint Provider Hosted Add-In and deployed the code on Azure. Trace.Writeline() doesnt seem to be working as I cant see anything in .../azurewebsite/trace.axd

I am able to see logs when I deployed a normal ASP.NET MVC application on Azure on .../azurewebsite/trace.axd but unable to find logs when Proivder Hsoted Add-In is deployed to Azure and .app is installed on SharePoint Online

EDIT: Able to get trace and error messages in Controllers of ASP.NET MVC application as suggested by below answers but unable to get trace and error messages in /Services/RemoteEventReceiver.svc.cs file.


2 Answers 2


Add the following to the system.web section of your web.config file:

<trace enabled="true" localOnly="false" requestLimit="100" />

Or enable it as below via code:

public static void EnableTracing()
            Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");
            TraceSection section = (TraceSection)configuration.GetSection("system.web/trace");
            section.Enabled = true;
            section.LocalOnly = false;

After that to view trace logs, go to pages/trace.axd.

Do check out the excellent PnP code sample for this on how to trace and debug provider hosted app.

Debug and Trace Provider hosted app

  • Working on Controller files but not in /Services/RemoteEventReceiver.svc.cs file.
    – krishna
    Jan 10, 2017 at 9:36

Few points to check:

  1. In web.config add
         <add name="WebPageTraceListener"
             PublicKeyToken=b03f5f7f11d50a3a" />
  1. In web.config add (for remote localOnly="false"):
<trace enabled="true" localOnly="false" writeToDiagnosticsTrace="true" mostRecent="true" pageOutput="false" />  
  1. In Azure portal, under your web app -> Monitoring -> Diagnostic logs, make sure application logging is enabled and level is Verbose (note this settings are disabled automatically in 12 hours):
    enter image description here

  2. Deploy your app and in Azure click Your web app -> Monitoring -> Log Stream. You should trace events from your app. You can also configure it to show traces right inside Visual Studio (in Server Explorer, right-click your web app and select View Streaming Logs.).

Must read article - Troubleshoot a web app in Azure App Service using Visual Studio


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.