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();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 |
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
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());
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
}
