serilog-sinks-mysql icon indicating copy to clipboard operation
serilog-sinks-mysql copied to clipboard

CloseAndFlush don't work

Open 0n2ynu opened this issue 1 year ago • 0 comments


  protected override async void OnExit(ExitEventArgs e)
        {
            try
            {
                _mutex?.ReleaseMutex();
                _mutex?.Close();
            }
            catch (Exception)
            {
                // ignored
            }
            finally
            {
                if (e.ApplicationExitCode == 0)
                {
                    Log.Information("exit");
                    await Log.CloseAndFlushAsync();
                    await Dal.DalBase.Save2DbAsync(new ActionLog("exit"));
                }

                base.OnExit(e);
            }

Always miss the last few message in mysql . And i find out that sink to file is ok. Seems CloseAndFlushAsync() has some issues.

0n2ynu avatar Oct 23 '23 07:10 0n2ynu