Thundra's .NET agent provides two modes of logging. The simple way to log is via the console using the
Console method of C#. Therefore,
Console.WriteLine("Hello") would log the message
“hello” to the Thundra console.
The second way to log messages to the console involves using the Microsoft Logging extension, where you use
LoggerFactory and add the Thundra provider as described in the following sections.
Thundra Logger is built on top of Microsoft's logging extension with ASP.NET. Therefore, when you create a new instance of
LoggerFactory(), you must add the Thundra logger as well:
LoggerFactory().AddThundraProvider(). After that, you may create a logger by using the
CreateLogger<FunctionName>() method of the Logger Factory and then start to log with the levels present.
According to the LoggerExtension the following levels are present:
The code snippet below is a basic example illustrating how you can set up Thundra's logger.
var loggerFactory = new LoggerFactory().AddThundraProvider();var logger = loggerFactory.CreateLogger<Function>();
There are three configurations that you can set in different ways. The configurations are:
Setting the minimum log level
Disabling console logging
Disabling log data completely
Configuration of .NET logs can be done in three different ways. These involve programmatic configurations, configuration via environment variables, and user configuration files. All log data is enabled by default, and the minimum log level is
Trace with priority level 0.
ThundraConfig config = ThundraConfigProvider.GetThundraConfig();config.DisableLog = "false";config.LogLevel = "trace"config.DisableConsoleLog = "true"
You can change log levels using the environment variable
thundra_agent_lambda_log_disable or by programmatically changing ThundraConfig's
You can disable console logs using the environment variable
thundra_agent_lambda_log_console_disable or by programmatically changing ThundraConfig's
Log monitoring is disabled by default, but can be enabled by setting the relevant configuration parameters. These parameters include the
thundra_agent_lambda_log_disable environment variable and the
disable_log object initialization parameter.