DbUp.Extensions.Microsoft.Logging extends DbUp logging by enabling using Microsoft.Extensions.Logging.ILogger that's registered in Microsoft Dependency Injection (i.e., IServiceProvider)
The two ways to use this extension are described below. Both have the same result, but are different ways to pass in the logger.
- Add
using DbUp.Extensions.Logging;
- Call
AddLoggerFromServiceProvider()
on theUpgradeEngineBuilder
passingIServiceProvider
as an argument. Check the example below.
DeployChanges.To
.SqlDatabase(con)
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly())
.AddLoggerFromServiceProvider(serviceProvider)
.Build();
- Add
using DbUp.Extensions.Logging;
- Call
AddLogger()
on theUpgradeEngineBuilder
passingILogger<UpgradeEngine>
as an argument. Check the example below.
DeployChanges.To
.SqlDatabase(con)
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly())
.AddLogger(logger)
.Build();