Search code examples
logginghttpsserilog

I plan to use Serilog in production environment, so is there any performance issue to Log all levels (Info, warning, errors, ...) over HTTPs?


I am new to serilog and I plan to use it in production environment, so is there any performance issue to send all Log levels (Info, warning, errors, etc..) over HTTPs to a web api that I have created and this api will just write logs to file as I don't want to write log files on the production server for security issues unless there is an out of the box way to encrypt them?


Solution

  • As with everything, it depends. You have to define your requirements for logging and for performance before you can answer your own question.

    Examples:

    • Do you need to send the log messages immediately, or can you send them asynchronously in the background, and get the messages with some delay?
    • Do you need messages to be sent one-by-one, or can you send them in batches?
    • Can you afford to lose messages or should the app stop if a log message cannot be written?

    These answers will help you decide how you're going to configure your Serilog logging pipeline and which Sinks to use (or even develop).

    Check the configuration options available in the sinks you're planning to use (e.g. batchPostingLimit, period, queueLimit if you're using Serilog.Sinks.Http), and take a look at the Serilog.Sinks.Async which allows you to delegate the logging to a background thread if your sink doesn't implement that out-of-the-box.

    As for performance, you'll have to measure it and decide what's acceptable for your application.