Is it safe to use static `Serilog.ILogger`
I am using Serilog . I want to write log entries from the SourceContext
containing class.
Is it safe (including thread safe):
using Serilog;
...
class Foo
{
private static readonly ILogger Log =
Serilog.Log.ForContext<Foo>();
/* Invoke Log.Debug(...) etc. in other methods */
}
There is a small example in the documentation (linked) that adds context inside a method , instead of creating one to share for the type above. I would prefer not to enter the same boiler plate code in every method where I register. Empirically, the above seems to work, but can anyone suggest a definitive guide?
+3
source to share