diff options
| author | JP Dillingham <jp@dillingham.me> | 2026-09-03 09:03:07 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-03 09:03:07 -0500 |
| commit | 2602fb0e821d9af36d917d2f54d071f5d00e144f (patch) | |
| tree | e9ebbcf83530cfd4358bae89298a145d64069e0a | |
| parent | a7c3fb403ed965da7cf3967db8eac0db1729b648 (diff) | |
| parent | b311a31f18de891a026a4435818ac6ed563c1538 (diff) | |
| download | slskd-2602fb0e821d9af36d917d2f54d071f5d00e144f.tar.gz | |
Merge pull request #1829 from slskd/log-options
Enable logging to disk by default, reduce default retention from 180 to 30 days
| -rw-r--r-- | config/slskd.example.yml | 2 | ||||
| -rw-r--r-- | docs/config.md | 2 | ||||
| -rw-r--r-- | src/slskd/Core/Options.cs | 12 | ||||
| -rw-r--r-- | src/slskd/Program.cs | 4 |
4 files changed, 10 insertions, 10 deletions
diff --git a/config/slskd.example.yml b/config/slskd.example.yml index af2871e2..86b7b17f 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -195,7 +195,7 @@ # circuit_breaker: 500 # maximum number of pending search requests # response_file_limit: 500 # maximum number of files to return in a single search response # logger: -# disk: false +# no_disk: false # no_color: false # loki: ~ # metrics: diff --git a/docs/config.md b/docs/config.md index 0202d89b..2c21d12b 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1342,7 +1342,7 @@ Console colors can be disabled via typical application configuration described b | Command Line | Environment Variable | Description | | ------------------ | ------------------------------ | ---------------------------------- | -| `--disk-logger` | `SLSKD_DISK_LOGGER` | Enable logging to disk | +| `--no-disk-logger` | `SLSKD_NO_DISK_LOGGER` | Disable logging to disk | | `--no-color` | `SLSKD_NO_COLOR` or `NO_COLOR` | Disable console log colors | Logs can optionally be forwarded to external services, and the targets can be expanded to any service supported by a [Serilog Sink](https://github.com/serilog/serilog/wiki/Provided-Sinks). Support for targets is added on an as-needed basis and within reason. diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index d1062a2c..13a24eed 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1458,11 +1458,11 @@ namespace slskd /// <summary> /// Gets a value indicating whether to write logs to disk. /// </summary> - [Argument(default, "disk-logger")] - [EnvironmentVariable("DISK_LOGGER")] - [Description("enable logging to disk")] + [Argument(default, "no-disk-logger")] + [EnvironmentVariable("NO_DISK_LOGGER")] + [Description("disable logging to disk")] [RequiresRestart] - public bool Disk { get; init; } = false; + public bool NoDisk { get; init; } = false; /// <summary> /// Gets a value indicating whether to suppress colorization of console logs. @@ -1500,8 +1500,8 @@ namespace slskd /// <summary> /// Gets the time to retain logs, in days. /// </summary> - [Range(1, maximum: int.MaxValue)] - public int Logs { get; init; } = 180; + [Range(7, maximum: int.MaxValue)] + public int Logs { get; init; } = 30; /// <summary> /// Transfer retention options. diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 5260760f..c998d319 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -512,7 +512,7 @@ namespace slskd Log.Information("Storing application data in {DataDirectory}", DataDirectory); - if (OptionsAtStartup.Logger.Disk) + if (!OptionsAtStartup.Logger.NoDisk) { Log.Information("Saving application logs to {LogDirectory}", LogDirectory); } @@ -1242,7 +1242,7 @@ namespace slskd outputTemplate: (OptionsAtStartup.Debug ? "[{SourceContext}] " : string.Empty) + "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}") .WriteTo.Async(config => config.Conditional( - e => OptionsAtStartup.Logger.Disk, + e => !OptionsAtStartup.Logger.NoDisk, config => config.File( Path.Combine(LogDirectory, $"{AppName}-.log"), outputTemplate: (OptionsAtStartup.Debug ? "[{SourceContext}] " : string.Empty) + "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}", |
