diff --git a/templates/console/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj b/templates/console/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj index 2ea0513d71..a2041bf970 100644 --- a/templates/console/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj +++ b/templates/console/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj @@ -14,6 +14,7 @@ + diff --git a/templates/console/src/MyCompanyName.MyProjectName/MyProjectNameHostedService.cs b/templates/console/src/MyCompanyName.MyProjectName/MyProjectNameHostedService.cs index 318e5a5508..756d56571e 100644 --- a/templates/console/src/MyCompanyName.MyProjectName/MyProjectNameHostedService.cs +++ b/templates/console/src/MyCompanyName.MyProjectName/MyProjectNameHostedService.cs @@ -2,12 +2,8 @@ using System.Threading.Tasks; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; using Serilog; -using Serilog.Extensions.Hosting; -using Serilog.Extensions.Logging; using Volo.Abp; namespace MyCompanyName.MyProjectName; @@ -33,13 +29,7 @@ public class MyProjectNameHostedService : IHostedService options.Services.AddSingleton(_hostEnvironment); options.UseAutofac(); - - // UseSerilog() - options.Services.AddLogging(); - options.Services.Replace(ServiceDescriptor.Singleton()); - var implementationInstance = new DiagnosticContext(null); - options.Services.AddSingleton(implementationInstance); - options.Services.AddSingleton((IDiagnosticContext) implementationInstance); + options.Services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true)); }); await _abpApplication.InitializeAsync(); diff --git a/templates/wpf/src/MyCompanyName.MyProjectName/App.xaml.cs b/templates/wpf/src/MyCompanyName.MyProjectName/App.xaml.cs index 46ddd64910..21124d6400 100644 --- a/templates/wpf/src/MyCompanyName.MyProjectName/App.xaml.cs +++ b/templates/wpf/src/MyCompanyName.MyProjectName/App.xaml.cs @@ -1,12 +1,8 @@ using System; using System.Windows; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Logging; using Serilog; using Serilog.Events; -using Serilog.Extensions.Hosting; -using Serilog.Extensions.Logging; using Volo.Abp; namespace MyCompanyName.MyProjectName; @@ -38,13 +34,7 @@ public partial class App : Application _abpApplication = await AbpApplicationFactory.CreateAsync(options => { options.UseAutofac(); - - // UseSerilog() - options.Services.AddLogging(); - options.Services.Replace(ServiceDescriptor.Singleton()); - var implementationInstance = new DiagnosticContext(null); - options.Services.AddSingleton(implementationInstance); - options.Services.AddSingleton((IDiagnosticContext) implementationInstance); + options.Services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true)); }); await _abpApplication.InitializeAsync(); diff --git a/templates/wpf/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj b/templates/wpf/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj index afb8fcfb4c..6b5352c3e7 100644 --- a/templates/wpf/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj +++ b/templates/wpf/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj @@ -15,6 +15,7 @@ +