Export (0) Print
Expand All

How to: Enable Diagnostics

You can find and fix errors that occur in the code that you write by debugging your application. There are, however, errors that can occur outside the code that you write. For example, there are many issues that could prevent your application from communicating with a server. To find and fix these types of errors, LightSwitch provides diagnostic capabilities both at design time and for a deployed application. Diagnostics is accomplished by enabling tracing on the client or on the server.

Note Note

Server-side tracing for an application deployed to Internet Information Services (IIS) or Windows Azure works the same as for any other deployed application or website. Consult the documentation for the version of IIS or Windows Azure that you are using for more information.

To enable client tracing at design time

  1. In Solution Explorer, double-click Properties to open the Application Designer.

  2. On the Application Type tab, in the Client section, select Web.

  3. On the View menu, click Other Windows and then click Output to display the Output window.

  4. On the Debug menu, click Start Debugging.

  5. In the address bar of the browser, add client tracing arguments to the end of the URL as follows:

    • To display an error-level trace, type LC=Microsoft.LightSwitch,E.

    • To display a warning-level trace, type LC=Microsoft.LightSwitch,W.

    • To display an information-level trace, type LC=Microsoft.LightSwitch,I.

    • To display a verbose trace, type LC=Microsoft.LightSwitch,V.

    For example, following is the full URL for a verbose trace for an application named myapp.

    http://myapp/default.htm?LC=Microsoft.LightSwitch,V
    

    The application restarts and trace messages appear in the Output window.

To enable server tracing at design time

  1. In Solution Explorer, click the Logical View button and then click File View.

  2. Click the Show All Files button.

  3. Expand the ServerGenerated node and double-click the Web.config file to open it.

  4. In the <appSettings> section, find the line <add key=”Microsoft.LightSwitch.Trace.Enabled” value=”false” /> and change false to true.

  5. Close the Web.config file, and when you are prompted to save changes click Yes.

  6. In Solution Explorer, double-click Properties to open the Application Designer.

  7. Select the Application Type tab and in the Client section select Web.

  8. Press F5 to run the application. The application will open in your default Web browser.

  9. Copy the first part of the URL from the Address Bar of the browser. It should resemble http://localhost:12345, but with a different numeric value.

  10. Open a new Web browser window or tab, and in the Address Bar paste the URL that you copied, and then type /Trace.axd. It should resemble http://localhost:12345/Trace.axd.

    This will display trace information for server operations.

To enable client tracing for a deployed 3-tier Web application

  1. Open a Web browser and navigate to the URL for the application.

  2. In the address bar of the browser, add client tracing arguments to the end of the URL as follows:

    • To display an error-level trace, type LC=Microsoft.LightSwitch,E.

    • To display a warning-level trace, type LC=Microsoft.LightSwitch,W.

    • To display an information-level trace, type LC=Microsoft.LightSwitch,I.

    • To display a verbose trace, type LC=Microsoft.LightSwitch,V.

    For example, following is the full URL for a verbose trace for an application named myapp.

    http://myapp/default.htm?LC=Microsoft.LightSwitch,V
    
  3. View the trace messages in a debug viewer. Any debug viewer that can listen to debug output messages can be used to view LightSwitch trace messages.

Community Additions

ADD
Show:
© 2015 Microsoft