Created
January 2, 2016 21:52
-
-
Save hikalkan/78a93f4da24666a2e971 to your computer and use it in GitHub Desktop.
Enabling Serilog in an ABP based Web project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Remove this: | |
AbpBootstrapper.IocManager.IocContainer | |
.AddFacility<LoggingFacility>(f => f.UseLog4Net() | |
.WithConfig("log4net.config") | |
); | |
//Add this: | |
AbpBootstrapper.IocManager.IocContainer.Register( | |
Component | |
.For<LoggerConfiguration>() | |
.UsingFactoryMethod( | |
() => new LoggerConfiguration() //Configure Serilog here! | |
.WriteTo.ColoredConsole() | |
.MinimumLevel.Debug() | |
).LifestyleSingleton(), | |
Component | |
.For<ILoggerFactory, SerilogFactory>() | |
.ImplementedBy<SerilogFactory>() | |
.LifestyleSingleton(), | |
Component | |
.For<ILogger>() | |
.UsingFactoryMethod((kernel, componentModel, creationContext) => | |
{ | |
return kernel.Resolve<ILoggerFactory>().Create(creationContext.Handler.ComponentModel.Name); | |
}) | |
.LifestyleTransient() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before it, we need to
And import some namespaces