<PackageReference Include="OpenTelemetry" Version="1.20.0" />

OpenTelemetry.SelfDiagnostics.SelfDiagnosticsOptions

public sealed class SelfDiagnosticsOptions
Options for configuring SDK self-diagnostics logging.

Gets or sets how much of the OTEL_* environment variable snapshot is written to the log file preamble. Defaults to KnownSafeValues, which lists every variable name but redacts the value of any variable the SDK does not recognise as safe to disclose.

public int FileSizeLimitKilobytes { get; set; }

Gets or sets the maximum size of a single log file in kilobytes before it rolls over to a new file. Defaults to 10240 (10 MiB). A value less than or equal to zero disables size-based rollover. Files are never truncated; a new file is opened when the limit is reached. Positive values are not clamped to a minimum. A file may exceed the limit by its preamble and by the entry that crosses the boundary, so very small values can cause a rollover after nearly every entry.

public string LogDirectory { get; set; }

Gets or sets the folder where self-diagnostics log files are written. Set this to use a specific folder. Leave it null or empty to leave file logging unset; if OTEL_DOTNET_SELF_DIAGNOSTICS_SINKS requests file, the SDK may still choose a default folder.

public bool LogToStderr { get; set; }

Gets or sets a value indicating whether SDK diagnostics are written to standard error. When only this flag is set all entries are written to standard error. When both this flag and LogToStdout are set, entries above Warning are written to standard error and entries at Warning and below are written to standard output.

public bool LogToStdout { get; set; }

Gets or sets a value indicating whether SDK diagnostics are written to standard output. When only this flag is set all entries are written to standard output. When both this flag and LogToStderr are set, entries at Warning and below are written to standard output and entries above Warning are written to standard error.

public int MaxRetainedFiles { get; set; }

Gets or sets the maximum number of rolling log files to retain. Defaults to 10. When a new file is opened the oldest is deleted if this limit would be exceeded. Values less than or equal to zero disable automatic pruning, so files are retained until they are removed externally.

public LogLevel MinimumLevel { get; set; }

Gets or sets the minimum log level. Events below this level are discarded. Defaults to Warning.

Initializes a new instance of the SelfDiagnosticsOptions class.

public static string GetDefaultLogDirectory()

Resolves the platform-appropriate per-user directory used when the file sink is enabled without an explicit LogDirectory.