In the previous PRISM version, one could create a custom Log4Net adapter class (derived from ILoggerFacade
) and override the protected CreateLogger
method of the abstract Prism.Bootstrapper
class like the following:
protected override ILoggerFacade CreateLogger()
{
return new Log4NetAdapter();
}
In the newer PRISM 7 version, all methods of the Bootstrapper
class were moved to the PrismApplicationBase
class. However, the virtual CreateLogger
method cannot be found anymore.
Question: How can PRISM 7 be configured to use a custom Log4Net adapter?
The CreateLogger
method does not exist anymore in Prism 7. You can just register your custom logger as ILoggerFacade
in the container by overriding RegisterTypes
in your PrismApplication
.
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterSingleton<ILoggerFacade, CustomLogger>();
}
If you already have created an instance of your logger before, you can register it like this.
containerRegistry.RegisterInstance(logger);