Logging Information and Errors in Creatio C# Code and Viewing from Cloud Hosted Systems

If you’re developing client side code for Creatio viewing information about what is happening at runtime is easy since you can output anything to the console. If you’re developing C# code, or need to debug C# code – even in a cloud hosted system, the best approach is to use a logger.

We can use a logger to log info, error, etc messages. To view these messages, we’ll use Clio Explorer, which is an add-on for Visual Studio Code.

View information about Clio Explorer

Using the log viewer built-into Clio Explorer we can view our logging information in real time, as things occur. The end result will be viewing logging messages like this:

In the image above, notice the message from “CfxLogger” that reads “Testing at 2/23/2024 11:59:39 PM”. That message was received from C# code running in Creatio as it was happening. Meaning, the logging message appeared just as the information was logged.

To use logging in your C# code in Creatio, you’ll need to include a using statement for the following namespace:

global::Common.Logging

If your C# code is in a script task in a process, be sure to add that in the methods tab of the process properties.

With that added we can add logging messages. First, we must create a logger. In the sample below I am giving my logger a name. This name can be anything. Having a unique name gives you something specific to look for in the logging output.

var logger = LogManager.GetLogger("CfxLogger");

With the logger created we can use the Info, Error, Warn etc functions to add logging messages of different types. This name is what we’ll use to listen for messages from in VSCode/Clio Explorer.

//create the logger 
var logger = LogManager.GetLogger("CfxLogger");

// log an info message
logger.Info("This is my test info message");

// log an error
logger.Error("Something bad happened!");

// log a warning
logger.Warn("Something sort of bad happened.");

Now, when this runs the information can be views using Clio Explorer. In Clio Explorer click the ellipsis button for the environment and then select logs.

Enter your logger name and click Start to begin listening for the messages and you’ll see them appear as they occur.

Alternatively, instead of using Clio Explorer, you can use the Telemetry Log from the Creatio marketplace to listen for the messages.

Want content like this delivered to your inbox? Sign up for our newsletter!
ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *