From 4cb39a34b57f9b392f27e3935c697436f088d59f Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Wed, 2 Aug 2023 18:25:41 +0500 Subject: [PATCH] Add logging to file (#75) This PR adds the package `Serilog.Extensions.Logging.File` to add logging to file. I decided this was necessary after the bot unexpectedly went down in a tmux session, leaving no traces behind. ![image](https://github.com/TeamOctolings/Boyfriend/assets/61277953/b6ff9e69-b370-4844-b552-db4a39933f62) --------- Signed-off-by: Octol1ttle --- Boyfriend.csproj | 1 + src/Boyfriend.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Boyfriend.csproj b/Boyfriend.csproj index 366d1c5..6550e3e 100644 --- a/Boyfriend.csproj +++ b/Boyfriend.csproj @@ -28,6 +28,7 @@ + diff --git a/src/Boyfriend.cs b/src/Boyfriend.cs index d1c4f7a..322b65a 100644 --- a/src/Boyfriend.cs +++ b/src/Boyfriend.cs @@ -18,6 +18,7 @@ using Remora.Discord.Gateway.Extensions; using Remora.Discord.Hosting.Extensions; using Remora.Discord.Interactivity.Extensions; using Remora.Rest.Core; +using Serilog.Extensions.Logging; namespace Boyfriend; @@ -95,8 +96,12 @@ public class Boyfriend { } ).ConfigureLogging( c => c.AddConsole() + .AddFile("Logs/Boyfriend-{Date}.log", + outputTemplate: "{Timestamp:o} [{Level:u4}] {Message} {NewLine}{Exception}") .AddFilter("System.Net.Http.HttpClient.*.LogicalHandler", LogLevel.Warning) .AddFilter("System.Net.Http.HttpClient.*.ClientHandler", LogLevel.Warning) + .AddFilter("System.Net.Http.HttpClient.*.LogicalHandler", LogLevel.Warning) + .AddFilter("System.Net.Http.HttpClient.*.ClientHandler", LogLevel.Warning) ); } }