Search code examples
wpfloggingprismserilog

How to implement Serilog in a Prism WPF application?


I am trying to implement Serilog in our enterprise WPF application built using Prism Library. Google search shows that I need to implement a custom class that inherits from ILoggerFacade but I don't know how to do that because the function void Log(string message, Category category, Priority priority); does not log the messages in the format I would like to and I would like to implement a custom logger that has the properties of Serilog.

How do I do this ?


Solution

  • TL;DR; Just use the Prism.Logging.Serilog library.


    All you have to do is create a class that implements ILoggerFacade, and that forwards log messages to your Serilog logger. Use an instance of that class when you configure your Prism bootstrapper.

    Use that class on your bootstrapper.

    Everywhere else in your application, you can use Serilog's ILogger and completely forget about ILoggerFacade...