Debugging in templates and code in the CMS

RichardHamlyn
Crownpeak (Retired)
2 1 2,491

This article aims to help you get started with basic debugging/logging in Crownpeak DXM.  It will cover two different methods of debugging, for templates and code snippets.

Templates

As a Developer, you need to switch on the Template Debugger before you start.

  • In the CMS, go to Settings -> Users/Groups -> Users and search for your account.
  • Open your User account by double-clicking from within the list.  Switch to Preferences and check the Content Debug box, as shown:

Screenshot 54.png

 

  • Save and close your profile settings.
  • Now, go back into the CMS and open the template output.aspx that you want to debug.
  • Add your debug line:
    <%
    Out.DebugWriteLine("Some debug identifier");
    %>
  • Open an asset that employs the template you just added debugging to.
  • At the top of the Main Window in the CMS, you will see a debug icon, click on this to see the debug console open at the bottom of the Main Window.

Screenshot 2.png

Screenshot.png

 

 

  • Refresh the asset (page).
  • You will see the debug statement in the console.

Screenshot 1.png

Code

If you want to debug in an aspx file, that will not run in a template, for example, in a workflow step, then you can do this by adding a log entry to your code.

 

<%
Util.Log(asset, "My debugging for asset ID: " + asset.Id + " is found here!");
%>

 

 When the code is called, you will be able to access your log, which contains your debug information, by:

  • In the CMS, go to Reports -> Audit -> System.
  • Change the filter to 'Custom'.  Click Search.

Screenshot 4.png

As you can see from the above screenshot, my log information is displayed in the list.

Note!

The code debugging is often used when you create classes or coded functions that interact with a template or workflow in the CMS.  For example, this may be to call a third-party API, such as translation services or to run a function on post_save or post_publish events.

1 Comment
kensnyder
Head of Support
Head of Support

When using Util.Log, asset is not required.  However by including the asset in the logging, you can locate it easier in the System Audit as you can filter on the asset id.  Further if accessing history from the asset properties, it will automatically populate asset id in the Audit report, though you still need to change the Action to Custom as noted.

Version history
Last update:
‎04-09-2020 02:25 PM
Updated by: