Conga Product Documentation

Welcome to the new doc site. Some of your old bookmarks will no longer work. Please use the search bar to find your desired topic.

LogHelper

Use LogHelper to log runtime information from custom code for debugging and troubleshooting. Logged messages appear in the Telemetry Logs.

Best Practices

  • Use minimal logging in production code.
  • Add detailed logs temporarily during debugging or troubleshooting.
  • Remove extra log statements once the issue is resolved.

Obtaining and Using the LogHelper Instance

To use LogHelper, obtain its instance in your main implementation class that extends CodeExtensibility. You can then pass this instance to other classes as needed.

var logHelper = GetLogHelper();
Note: You can only create the LogHelper instance in the main implementation class. Avoid creating multiple instances. Reuse the instance and pass it to other classes where required.
Available Methods

Method

Description

void LogCritical(string message)

Use this method to log critical issues that require immediate attention.

void LogDebug(string message)

Use this method rarely. Prefer LogInformation or LogError unless detailed debugging information is absolutely necessary.

void LogError(string message)

Use this method to log errors that occur during the process.

void LogInformation(string message)

Use this method to log general information about the application's normal operations.

void LogWarning(string message)

Use this method to log warnings that may cause problems if not addressed.

Usage Example

Here is how you can use LogHelper in your callback code:
var logHelper = GetLogHelper();

logHelper.LogTrace("Trace Statement");
logHelper.LogDebug("Debug Statement");
logHelper.LogWarning("Warning Statement");
logHelper.LogInformation("Info Statement");

var exception = new Exception("SystemException");
logHelper.LogError("Error Message: " + exception.ToString());
Expected Console Output
Trace Statement
Debug Statement
Warning Statement
Info Statement
Error Message:
{
  "ClassName": "System.Exception",
  "Message": "SystemException",
  "Data": null,
  "InnerException": null,
  "HelpURL": null,
  "StackTraceString": null,
  "RemoteStackTraceString": null,
  "RemoteStackIndex": 0,
  "ExceptionMethod": null,
  "HResult": -2146233088,
  "Source": null,
  "WatsonBuckets": null
}