Get Logs Configuration Operation
-
Use
GetLogsConfigurationOperationto get the logs configuration. -
Learn more about RavenDB's logging system in the Logging article.
-
In this article:
Get logs configuration
- Sync
- Async
GetLogsConfigurationResult logsConfiguration = store
.Maintenance.Server.Send(new GetLogsConfigurationOperation());
GetLogsConfigurationResult logsConfiguration = await store
.Maintenance.Server.SendAsync(new GetLogsConfigurationOperation());
Syntax
public GetLogsConfigurationOperation()
Return Value
The result of executing GetLogsConfigurationOperation is a GetLogsConfigurationResult object:
public class GetLogsConfigurationResult
{
public LogsConfiguration Logs { get; set; }
public AuditLogsConfiguration AuditLogs { get; set; }
public MicrosoftLogsConfiguration MicrosoftLogs { get; set; }
public AdminLogsConfiguration AdminLogs { get; set; }
}
LogsConfiguration
public class LogsConfiguration
{
// Path to the directory where log files are written.
public string Path { get; set; }
// The default minimum log level, as defined in the `Logs.MinLevel` setting in settings.json.
// This value is loaded once into memory when the server starts and remains unchanged at runtime.
public LogLevel MinLevel { get; set; }
// The currently active minimum log level, which determines the lowest level of log entries
// that will be written to the log files on disk.
//
// This value can be changed at runtime from the Studio or via the Client API
// using the `SetLogsConfigurationOperation` method.
// If not explicitly set, it falls back to the `MinLevel` value from settings.json.
public LogLevel CurrentMinLevel { get; set; }
// A list of active log filters that determine whether specific log entries
// should be included or excluded.
// Filters can be set from the Studio or via the Client API.
public List<LogFilter> CurrentFilters { get; set; } = new();
// This action does Not apply when no filters are defined.
// This action applies in the following cases:
// * When a log entry does Not match any defined filter.
// * When a log entry matches a filter with a 'Neutral' action,
// provided that no subsequent filters apply.
public LogFilterAction CurrentLogFilterDefaultAction { get; set; }
// Maximum size (in MB) a log file can reach before it is archived.
public long ArchiveAboveSizeInMb { get; set; }
// Maximum number of days to retain archived log files.
// Older files will be deleted.
public int? MaxArchiveDays { get; set; }
// Maximum number of archived log files to keep.
// Older archives beyond this limit will be deleted.
public int? MaxArchiveFiles { get; set; }
// When true, archived log files will be compressed to reduce disk space.
public bool EnableArchiveFileCompression { get; set; }
}
public class LogFilter
{
// A log entry matches the filter if:
// - its log level is between MinLevel and MaxLevel (inclusive),
// - it passes the global minimum level ('CurrentMinLevel'), and
// - it satisfies the condition.
// The minimum log level this filter applies to.
public LogLevel MinLevel { get; internal set; }
// The maximum log level this filter applies to.
public LogLevel MaxLevel { get; internal set; }
// An NLog expression evaluated against the log entry; must return true for the filter to match.
public string Condition { get; internal set; }
// The action to take when a log entry matches this filter.
// Determines whether the entry is logged, ignored, or passed to the next filter.
public LogFilterAction Action { get; internal set; }
}
public enum LogLevel
{
Trace = 0,
Debug = 1,
Info = 2,
Warn = 3,
Error = 4,
Fatal = 5,
Off = 6
}
public enum LogFilterAction
{
// The action to take is deferred to the next filter that matches the log entry.
// If no other filter matches, the "Default Filter Action" will be applied.
Neutral,
// The log entry will be logged.
Log,
// The log entry will Not be logged.
Ignore,
// The log entry will be logged.
// Any subsequent filters with the same logging-rules as this filter will be ignored.
LogFinal,
// The log entry will Not be logged.
// Any subsequent filters with the same logging-rules as this filter will be ignored.
IgnoreFinal
AuditLogsConfiguration
Learn more about RavenDB's audit log in the Audit Log article.
public class AuditLogsConfiguration
{
public string Path { get; set; }
public LogLevel Level { get; set; }
public long ArchiveAboveSizeInMb { get; set; }
public int? MaxArchiveDays { get; set; }
public int? MaxArchiveFiles { get; set; }
public bool EnableArchiveFileCompression { get; set; }
}
MicrosoftLogsConfiguration
public class MicrosoftLogsConfiguration
{
public LogLevel CurrentMinLevel { get; set; }
public LogLevel MinLevel { get; set; }
}
AdminLogsConfiguration
The Admin Logs configuration controls which logs are shown in the Studio's Admin Logs view.
See section Logs on this view for details.
public class AdminLogsConfiguration
{
public LogLevel CurrentMinLevel { get; set; }
public List<LogFilter> CurrentFilters { get; set; } = new();
public LogFilterAction CurrentLogFilterDefaultAction { get; set; }
}