C# Serilog compress log messages before writing to a file?

Viewed 583

Right now we have an architecture wherein the application logs to the File and then fluentd pulls the log and pushes it to the elasticsearch, so in this case, we want to compress logs in order to utilize the space, does serilog support log compression before writing it to the file??

In another scenario, where the customer may log data that is more than 5mb, is it good to write the logs in file and then push to the elastic search via fluentd? I feel it will impact and lead to failure, any idea how to push messages that are more than 5mb or around 10mb to elastic search.

Sample Code written:

 .UseSerilog((hostingContext, loggerConfiguration) =>
                {
                    loggerConfiguration.MinimumLevel.Debug()
                            .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                            .Enrich.FromLogContext()
                            .WriteTo.File(path: Path.Combine(Environment.CurrentDirectory, "Logs", "log.txt"),
                                rollOnFileSizeLimit: true,
                                retainedFileCountLimit: 20,
                                rollingInterval: RollingInterval.Day,
                                fileSizeLimitBytes: 10000
                                )
                            .WriteTo.Console();
                })
1 Answers
Related