As Nicholas pointed out in his answer, Log.Error()
& Log.Logger.Error()
are the same; Log.Logger.Error()
just forward the call to Log.Error()
. Or is it vice versa? I forget.
If no logger has been assigned to the static Log.Logger
instance, then the OOB SilentLogger
is used. Where all logging is "swallowed" by the SilentLogger
.
If you really want to use the static Log.Logger
instance, then a logger needs to be assigned. For example, the quickest/easiest logger to create/assign is the ConsoleLogger
:
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.CreateLogger();
Once you've assigned the ConsoleLogger
, all logging will be output to the console. Other types of loggers can be assigned as well.
Best practices would recommend using Dependency Injection, though. Review the Serilog Configuration Basics for more information.