#2243·serilog

Can I access the active Sink(s) to force a FlushToDisk?

Author: IainS1986Created Jul 30, 2026Updated Aug 3, 2026

Hi

I've seen a few discussions and reports on the desire to have a 'Flush' function to force a flush without closing/disposing but I'm not sure it was ever possible.

I know IFlushableFileSink has a FlushToDisk function, is there anyway to get the current active Sinks (or can I create one and keep a reference too it?) so I could call it manually?

My scenarios are,

  • We are using .net10 on .net-ios and .net-android (not MAUI). We have some hooks for unhandled exceptions which before we could manually write to file etc - but now we use Serilog and I'd ideally like to force a flush to disk (I know it might not happen in time if the OS tears down the application). I guess I could dispose in these instances?

  • We also have the ability for users to 'send' logs to our support, or internal builds to share the log files, ideally I'd want to call a Flush at this point - otherwise the relevant information the user is sending the support details for might not be in the file yet.

Alternative I guess, I call CloseAndFlush and then call my Log.Logger = new LoggerConfiguration().WriteTo.ect.ect again?