Search code examples
serilog

Not seeing Serilog CloseAndFlush


Just getting into SeriLog. Should mention now that this a class library in .Net standard (i.e. not Core). Using SeriLog 2.10.0, Sinks.File 4.1.0, and Sinks.MSSqlServer 5.6.0.

Having issues with the SQL Server sink, and realized that I was not calling CloseAndFlush like all the examples said I should do. Problem is it is not available, Intellisense doesn't even show it. Key parts of my code, the class constructor and method GetCB: enter image description here

enter image description here

so why am I not seeing CloseAndflush? I'll post my other issues later. :) Thanks.


Solution

  • The method is in the static Log class.

    Serilog.Log.CloseAndFlush();
    

    Also you should know that this method needs to be called only once in the application life cycle. For example when the application ends.