Skip to content

Commit b070182

Browse files
Added serilog as default logging service.
1 parent 51fb53b commit b070182

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/DotNetElements.AppFramework.AspNet/DotNetElements.AppFramework.AspNet.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<ProjectReference Include="..\DotNetElements.AppFramework\DotNetElements.AppFramework.csproj" />
14+
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<ProjectReference Include="..\DotNetElements.AppFramework\DotNetElements.AppFramework.csproj" />
1519
</ItemGroup>
1620

1721
</Project>

src/DotNetElements.AppFramework.AspNet/WebApplicationBuilderExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using DotNetElements.AppFramework.AspNet.Modules;
44
using Microsoft.AspNetCore.Builder;
55
using Microsoft.Extensions.DependencyInjection;
6+
using Serilog;
67

78
namespace DotNetElements.AppFramework.AspNet;
89

@@ -14,6 +15,10 @@ public static WebApplicationBuilder AddAppFramework(this WebApplicationBuilder b
1415

1516
builder.Services.AddHttpContextAccessor();
1617
builder.Services.AddScoped<ICurrentUserProvider, CurrentUserProvider>();
18+
builder.Services.AddSerilog((services, options) =>
19+
{
20+
options.ReadFrom.Configuration(builder.Configuration);
21+
});
1722

1823
builder.RegisterModules(moduleAssembly);
1924

src/DotNetElements.AppFramework.AspNet/WebApplicationExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
using DotNetElements.AppFramework.AspNet.Modules;
22
using Microsoft.AspNetCore.Builder;
3+
using Serilog;
34

45
namespace DotNetElements.AppFramework.AspNet;
56

67
public static class WebApplicationExtensions
78
{
89
public static WebApplication UseAppFramework(this WebApplication app)
910
{
11+
app.UseSerilogRequestLogging();
12+
1013
app.MapModuleEndpoints();
1114

1215
return app;

0 commit comments

Comments
 (0)