Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 4c00fb4

Browse files
authored
Merge pull request #10 from tsimbalar/readme [Skip CI]
Properly document the enrichers included in the package
2 parents f0efa49 + a27494f commit 4c00fb4

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,35 @@ ASP.NET WebAPI support for [SerilogWeb.Classic](https://github.com/serilog-web/c
44

55
*Package* - <a href="https://www.nuget.org/packages/serilogweb.classic.webapi">SerilogWeb.Classic.WebApi</a> | Platforms - .NET 4.5
66

7-
This package is used in conjunction with _SerilogWeb.Classic_ to support
8-
logging WebAPI exceptions with [Serilog](http://serilog.net).
7+
_This package is designed for full framework ASP.NET applications. For ASP.NET Core, have a look at [Serilog.AspNetCore](https://github.com/serilog/serilog-aspnetcore)_
98

9+
This package is used in conjunction with _SerilogWeb.Classic_ and adds :
10+
- support for logging WebAPI exceptions with [Serilog](http://serilog.net)
11+
- Web API specific enrichers
1012

13+
## Enrichers
14+
The following enrichers are available in the `SerilogWeb.Classic.WebApi.Enrichers` namespace:
15+
- **WebApiActionNameEnricher** : adds a property `WebApiAction` containing the name of the *Action* being executed in the *Web API Controller*
16+
- **WebApiControllerNameEnricher** : adds a property `WebApiController` containing the name of the *Controller* in which a *Web API Action* has executed
17+
- **WebApiRouteDataEnricher** : adds a property `WebApiRouteData` containing the dictionary of the *RouteData*
18+
- **WebApiRouteTemplateEnricher** : adds a property `WebApiRouteTemplate` containing the *route template* selected by Web API routing
1119

20+
21+
Usage :
22+
23+
```csharp
24+
var log = new LoggerConfiguration()
25+
.WriteTo.Console()
26+
.Enrich.With<WebApiRouteTemplateEnricher>()
27+
.Enrich.With<WebApiActionNameEnricher>()
28+
.CreateLogger();
29+
```
30+
31+
To override the property name of the added property:
32+
33+
```csharp
34+
var log = new LoggerConfiguration()
35+
.WriteTo.Console()
36+
.Enrich.With(new WebApiRouteTemplateEnricher("RouteTemplate")
37+
.CreateLogger();
38+
```

0 commit comments

Comments
 (0)