Logging
Catalytic SDK provides several options for logging configuration. Logging configuration options can be set via environment variables or directly on the static CatalyticClient
class.
Console Logging
By default, Console logging is disabled. The built-in Console logging can be set to one of 6 levels:
- Trace
- Debug
- Info
- Error
- Fatal
- Off [default]
You can change the Console logging level via the CATALYTIC_SDK_CONSOLE_LOG_LEVEL
environment variable or by setting the static CatalyticClient.ConsoleLogLevel
property.
/*
* This example demonstrates setting the Console log level to `Error`
*/
using Catalytic.Sdk;
namespace Catalytic.Sdk.Examples
{
class Program
{
static void Main(string[] args)
{
CatalyticClient.ConsoleLogLevel = "Error";
}
}
}
File Logging
By default, File logging is enabled at the Trace level, and output to {{CATALYTIC_SDK_PACAKGE_LOCATION}}/logs/logfile.txt
. The built-in File logging can be set to one of 6 levels:
- Trace [default]
- Debug
- Info
- Error
- Fatal
- Off
You can change the File logging level via the CATALYTIC_SDK_FILE_LOG_LEVEL
environment variable or by setting the static CatalyticClient.FileLogLevel
property.
You can change the File logging output file via the CATALYTIC_SDK_FILE_LOG_PATH
environment variable or by setting the static CatalyticClient.FileLogPath
property.
/*
* This example demonstrates setting the File log level to `Off`
*/
using Catalytic.Sdk;
namespace Catalytic.Sdk.Examples
{
class Program
{
static void Main(string[] args)
{
CatalyticClient.FileLogLevel = "Off";
}
}
}
Custom Configuration
For complete customization of Catalytic SDK logging, you can pass an NLog XML config file via the CATALYTIC_SDK_NLOG_XML_CONFIG_PATH
environment variable or by setting the static CatalyticClient.NLogXMLConfigPath
property. Providing this option disables the built-in Console and File logging.
/*
* This example demonstrates providing a custom NLog XML configuration file
*/
using Catalytic.Sdk;
namespace Catalytic.Sdk.Examples
{
class Program
{
static void Main(string[] args)
{
CatalyticClient.NLogXMLConfigPath = "path/to/NLog.config";
}
}
}
Updated about 3 years ago