Browse Source
Merge pull request #11315 from abpframework/console-template
`UseSerilog` for `Host`.
pull/11318/head
liangshiwei
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
2 additions and
1 deletions
-
templates/console/src/MyCompanyName.MyProjectName/MyProjectNameHostedService.cs
-
templates/console/src/MyCompanyName.MyProjectName/Program.cs
|
|
@ -29,7 +29,7 @@ public class MyProjectNameHostedService : IHostedService |
|
|
options.Services.AddSingleton(_hostEnvironment); |
|
|
options.Services.AddSingleton(_hostEnvironment); |
|
|
|
|
|
|
|
|
options.UseAutofac(); |
|
|
options.UseAutofac(); |
|
|
options.Services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true)); |
|
|
options.Services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog()); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
await _abpApplication.InitializeAsync(); |
|
|
await _abpApplication.InitializeAsync(); |
|
|
|
|
|
@ -32,6 +32,7 @@ public class Program |
|
|
{ |
|
|
{ |
|
|
services.AddHostedService<MyProjectNameHostedService>(); |
|
|
services.AddHostedService<MyProjectNameHostedService>(); |
|
|
}) |
|
|
}) |
|
|
|
|
|
.UseSerilog() |
|
|
.RunConsoleAsync(); |
|
|
.RunConsoleAsync(); |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
|