问题
Is it possible, using Serilog, to log to a webservice of mine and if throws an error (no internet, for instance) to log to a RollingFile. Should only log to RollingFile if WebService fails.
回答1:
You can implement this yourself by creating a custom sink that wraps another new RollingFileSink(...)
and only forwards events if the web service call fails.
To do this you'd implement ILogEventSink
or, if the web service accepts batches, create a subclass of PeriodicBatchingSink
.
来源:https://stackoverflow.com/questions/33533277/log-failover-with-serilog