Skip to content

Customize the Lightrun .NET agent

According to the Lightrun actions you specify, the agent dynamically inserts logs and snapshots in the target environment. The agent's behavior when performing these tasks is governed by a set of user-configurable properties.

Agent properties

You can specify the agent properties within your code, by using environment variables, or using an agent.config file.

Specifying agent properties within the code

You can specify your agent configuration parameters by entering the parameters in the LightrunAgent.Start command.

For example,

LightrunAgent.Start(new AgentOptions {
    Secret = "<LIGHTRUN_SECRET>",
    PropertyName1 = "value" ,
    PropertyName2 = "value",
});

Specifying agent properties using environment variables

An alternative method for configuring agent properties is to enter them as environment variables. This can be done by adding a LIGHTRUN_ prefix to the configuration parameter. For example, to set the Lightrun secret key and server url in a .env file, we would use something similar to the following:

//.env file

LIGHTRUN_SECRET=<lightrun_secret_key>
LIGHTRUN_SERVERURL=<lightrun_server_url>

Specifying agent properties using an agent.config file

You can also specify the agent properties using an agent.config file. Add the path to the agent.config file in your LightrunAgent.Start command using the AgentConfigFile parameter as shown in the example below.

LightrunAgent.Start(new AgentOptions {
   AgentConfigFile: '<PATH-TO-CONFIG>'
});

Order of precedence

When an application is run with a Lightrun agent, properties are defined in the following order of precedence:

  1. Start method parameter
  2. Environment variables
  3. agent.config file

Important

Whenever changing agent configurations, save the changes and restart the application to apply the new configuration.

Configuration parameters

The following table lists the configuration parameters that can be set in the agent.config file, environment variables, or the LightrunAgent.Start command.

Parameter name Description Type Default value
ServerUrl Lightrun server URL URL app.lightrun.com
Secret Your organization's Lightrun secret key String
Tags An array of strings containing the tags to register the agent with. When passing options to LightrunAgent.Start command, the corresponding property name is TagsCollection. See metadata and tagging for more information. Array Production
DisplayName A unique name to identify the agent. String
LogDir The directory in which internal agent logs file are stored. If the value is empty (undefined or empty string), the logs are transmitted to the console. String Temp Folder
LogToStandardError Switch to logging to STDERR instead of logging to a file. Boolean false
AlsoLogToStandardError Enable logging to STDERR additionally to logging to a file. Boolean false
FileLogLevel The log level for logging in file. AgentLogLevel AgentLogLevel.Information
StandardErrorLogLevel The log level for standard error. The setting is only applicable, when LogToStandardError or AlsoLogToStandardError is set to true. AgentLogLevel AgentLogLevel.Information
RegistrationMetadataFile Path to a JSON file containing the agent's registration metadata (such as tags, and display name). String
CertificatePinningEnabled Enable/disable certificate pinning. When set to false, the agent will not perform certificate pinning when communicating with the API endpoint. Boolean true
PinnedCerts 64 character sha256 public key certificates hashes for certificate pinning. When passing options to LightrunAgent.Start command, the corresponding property name is PinnedCertsCollection. String
enable_pii_redaction Enable personally identifiable information (PII) redaction at the agent's side (may affect the application's performance) Boolean false
CustomDynamicLogger Custom logger for dynamic logs. Follow the instructions here to configure the CustomDynamicLogger. IDynamicLogger
MaxStringLength Truncates strings to the set size. Integer 1000
MaxCollectionSize Truncate collections to set size. Integer 100
MaxFieldCount Maximum number of fields to capture on an object. Integer 20
MaxDepthToSerialize Maximum object depth to serialize. Integer 3
MaxTimeToSerializeMs Maximum time in milliseconds for serializing an object. Integer 200
MaxActionCost Maximum cost in % of CPU consumption of breakpoint callback. Double 1
IgnoreQuota Disable CPU cost limitation. Boolean false

Last update: April 21, 2024