Events
Mar 31, 11 PM - Apr 2, 11 PM
The ultimate Microsoft Fabric, Power BI, SQL, and AI community-led event. March 31 to April 2, 2025.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This article outlines the common steps for migrating a non-ASP.NET Core application that uses Microsoft.Extensions.Logging
from 2.1 to 2.2 or 3.0.
Manually create ServiceCollection
and call AddLogging
.
2.1 example:
using (var loggerFactory = new LoggerFactory())
{
loggerFactory.AddConsole();
// use loggerFactory
}
2.2 example:
var serviceCollection = new ServiceCollection();
serviceCollection.AddLogging(builder => builder.AddConsole());
using (var serviceProvider = serviceCollection.BuildServiceProvider())
using (var loggerFactory = serviceProvider.GetService<ILoggerFactory>())
{
// use loggerFactory
}
In 3.0, use LoggingFactory.Create
.
2.1 example:
using (var loggerFactory = new LoggerFactory())
{
loggerFactory.AddConsole();
// use loggerFactory
}
3.0 example:
using (var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()))
{
// use loggerFactory
}
ASP.NET Core feedback
ASP.NET Core is an open source project. Select a link to provide feedback:
Events
Mar 31, 11 PM - Apr 2, 11 PM
The ultimate Microsoft Fabric, Power BI, SQL, and AI community-led event. March 31 to April 2, 2025.
Register today