diff --git a/deploy/docker/docker-compose.yml b/deploy/docker/docker-compose.yml
index 041f38cb..f8f6c3c9 100644
--- a/deploy/docker/docker-compose.yml
+++ b/deploy/docker/docker-compose.yml
@@ -22,6 +22,8 @@ services:
TITANO_DB_PASSWORD: ${TITANO_DB_PASSWORD:?set TITANO_DB_PASSWORD in .env}
TITANO_TLS_MODE: auto
TITANO_SERVER_NAME: Titano Server
+ # Trace, Debug, Information, Warning or Error
+ TITANO_LOG_LEVEL: Information
PUID: ${PUID:-1000}
PGID: ${PGID:-1000}
TZ: ${TZ:-UTC}
diff --git a/deploy/unraid/titano.xml b/deploy/unraid/titano.xml
index 08649b6a..30fa9b4f 100644
--- a/deploy/unraid/titano.xml
+++ b/deploy/unraid/titano.xml
@@ -35,6 +35,7 @@
prefer
auto
Titano Server
+ Information
99
100
Europe/Rome
diff --git a/src/Titano.Server/Configuration/ServerOptions.cs b/src/Titano.Server/Configuration/ServerOptions.cs
index b6658bcc..1252c328 100644
--- a/src/Titano.Server/Configuration/ServerOptions.cs
+++ b/src/Titano.Server/Configuration/ServerOptions.cs
@@ -51,6 +51,7 @@ public sealed class ServerOptions
("TITANO_LANG", nameof(Language), (o, v) => o.Language = v),
("TITANO_WORKERS", nameof(Workers), (o, v) => o.Workers = Math.Max(1, Int("TITANO_WORKERS", v))),
("TITANO_DISCOVERY", nameof(Discovery), (o, v) => o.Discovery = bool.Parse(v)),
+ ("TITANO_LOG_LEVEL", nameof(LogLevel), (o, v) => o.LogLevel = Enum.Parse(v, ignoreCase: true)),
];
public string ServerName { get; set; } = "Titano Server";
@@ -77,6 +78,9 @@ public sealed class ServerOptions
public string Language { get; set; } = "en";
public int Workers { get; set; } = Math.Max(1, Environment.ProcessorCount / 2);
public bool Discovery { get; set; } = true;
+
+ /// Least severe level written to the console and the log files.
+ public LogLevel LogLevel { get; set; } = LogLevel.Information;
public long MaxUploadBytes { get; set; } = 2L * 1024 * 1024 * 1024;
public int ChunkSizeBytes { get; set; } = 8 * 1024 * 1024;
public int JobHistoryDays { get; set; } = 90;
diff --git a/src/Titano.Server/Hosting/ServerHost.cs b/src/Titano.Server/Hosting/ServerHost.cs
index 96d8f237..a06cf32f 100644
--- a/src/Titano.Server/Hosting/ServerHost.cs
+++ b/src/Titano.Server/Hosting/ServerHost.cs
@@ -36,16 +36,17 @@ public static class ServerHost
var builder = WebApplication.CreateSlimBuilder(new WebApplicationOptions { Args = args, ContentRootPath = AppContext.BaseDirectory });
builder.Logging.ClearProviders();
+ builder.Logging.SetMinimumLevel(options.LogLevel);
builder.Logging.AddSimpleConsole(c => c.SingleLine = true);
builder.Logging.AddProvider(new FileLoggerProvider(new FileLogSink(options.LogPath, "server")));
builder.Logging.AddFilter("Microsoft.AspNetCore", Microsoft.Extensions.Logging.LogLevel.Warning);
- builder.Logging.AddFilter("Microsoft.Hosting.Lifetime", Microsoft.Extensions.Logging.LogLevel.Information);
+ builder.Logging.AddFilter("Microsoft.Hosting.Lifetime", options.LogLevel > Microsoft.Extensions.Logging.LogLevel.Information ? options.LogLevel : Microsoft.Extensions.Logging.LogLevel.Information);
// The archive module registers first, so a missing piece stops the server before it touches the database.
configureServices?.Invoke(builder.Services);
RequireArchiveModule(builder.Services);
- using var bootLoggerFactory = LoggerFactory.Create(l => l.AddSimpleConsole(c => c.SingleLine = true));
+ using var bootLoggerFactory = LoggerFactory.Create(l => l.AddSimpleConsole(c => c.SingleLine = true).SetMinimumLevel(options.LogLevel));
var bootLogger = bootLoggerFactory.CreateLogger("Titano.Server");
var certificate = CertificateStore.Load(options, bootLogger);
var database = ServerDatabase.OpenAsync(options, bootLogger, CancellationToken.None).GetAwaiter().GetResult();
diff --git a/tests/Titano.Server.Tests/Api/AdminTests.cs b/tests/Titano.Server.Tests/Api/AdminTests.cs
index bdae948e..e085f171 100644
--- a/tests/Titano.Server.Tests/Api/AdminTests.cs
+++ b/tests/Titano.Server.Tests/Api/AdminTests.cs
@@ -53,7 +53,7 @@ public sealed class AdminTests(TestContext context)
[Test]
public async Task LogsAreReadableButOnlyByName()
{
- await using var server = await TestServer.StartAsync(context);
+ await using var server = await TestServer.StartAsync(context, o => o.LogLevel = Microsoft.Extensions.Logging.LogLevel.Information);
var admin = await server.AdminAsync();
using var tail = await admin.GetAsync("/api/v1/logs?lines=20");
var lines = await tail.ReadAsync(ProtocolJson.Default.LogTailDto);
diff --git a/tests/Titano.Server.Tests/Hosting/StartupTests.cs b/tests/Titano.Server.Tests/Hosting/StartupTests.cs
index c375aaef..9ee621cb 100644
--- a/tests/Titano.Server.Tests/Hosting/StartupTests.cs
+++ b/tests/Titano.Server.Tests/Hosting/StartupTests.cs
@@ -44,7 +44,15 @@ public sealed class StartupTests(TestContext context)
[Test]
public void PartsBuildAQuotedPostgresConnectionString()
{
- var options = new ServerOptions { DbHost = "postgres", DbName = "titano", DbUser = "titano", DbPassword = "it's;secret", DbSslMode = "disable" };
+ var options = new ServerOptions
+ {
+ Database = DatabaseKind.Postgres, // the Windows default is SQLite
+ DbHost = "postgres",
+ DbName = "titano",
+ DbUser = "titano",
+ DbPassword = "it's;secret",
+ DbSslMode = "disable",
+ };
var settings = Titano.Data.Postgres.PostgresSettings.Parse(options.ToDatabaseOptions().ConnectionString);
Assert.Equal(("postgres", "titano", "it's;secret"), (settings.Host, settings.Database, settings.Password));
Assert.Equal(Titano.Data.Postgres.SslMode.Disable, settings.SslMode);
diff --git a/tests/Titano.Server.Tests/TestServer.cs b/tests/Titano.Server.Tests/TestServer.cs
index d08cacbd..a69b456d 100644
--- a/tests/Titano.Server.Tests/TestServer.cs
+++ b/tests/Titano.Server.Tests/TestServer.cs
@@ -66,6 +66,8 @@ public sealed class TestServer : IAsyncDisposable
AdminPassword = AdminPassword,
// Tests sign in many times from one address; the rate-limit test sets the production value.
LoginAttemptsPerMinute = 1000,
+ // Info lines of the ~55 servers the suite starts would bury failures in the CI log.
+ LogLevel = Microsoft.Extensions.Logging.LogLevel.Warning,
};
Directory.CreateDirectory(options.ArchivePath);
configure?.Invoke(options);