Closed josephwambura closed 2 years ago
You need to configure your sink to use the hook. To do this, you will first need to create a public static class that can provide the configuration system with a configured instance of ArchiveHooks
:
using Serilog.Sinks.File.Archive;
namespace MyApp.Logging;
public class SerilogHooks
{
public static ArchiveHooks MyArchiveHooks => new ArchiveHooks(CompressionLevel.Fastest, "C:\\My\\Archive\\Path");
}
You then specify that in your configuration, e.g.
<add key="serilog:write-to:File.hooks" value="MyApp.Logging.SerilogHooks::MyArchiveHooks, MyAssembly" />
I haven't actually verified the above XML config, but it should work.
In the example you posted, it looks like you are pointing towards the wrong config, unless your static class really is Serilog.Sinks.File.Archive.ArchiveHooks
in assembly Archive
?
I am trying to add this feature to my project, but it does not work.
<add key="serilog:write-to:File.hooks" value="Serilog.Sinks.File.Archive::ArchiveHooks, Archive" />
running on .Net 4.8 and using the xml config files.