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 <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-08-02 18:25:41 +05:00 committed by GitHub
parent 940f2e64a0
commit 4cb39a34b5
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -28,6 +28,7 @@
<PackageReference Include="Remora.Discord.Extensions" Version="5.3.2"/>
<PackageReference Include="Remora.Discord.Hosting" Version="6.0.7"/>
<PackageReference Include="Remora.Discord.Interactivity" Version="4.5.1"/>
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0"/>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="locale\Messages.resx">

View file

@ -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<SerilogLoggerProvider>("System.Net.Http.HttpClient.*.LogicalHandler", LogLevel.Warning)
.AddFilter<SerilogLoggerProvider>("System.Net.Http.HttpClient.*.ClientHandler", LogLevel.Warning)
);
}
}