Skip to content

Commit 8921773

Browse files
committed
README updates
1 parent 29f45f4 commit 8921773

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

README.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Install the package from NuGet:
1111
dotnet add package Serilog.Expressions
1212
```
1313

14-
The package adds extension methods to Serilog's `Filter` and
14+
The package adds extension methods to Serilog's `Filter`, `WriteTo`, and
1515
`Enrich` configuration objects, along with an `OutputTemplate`
1616
type that's compatible with Serilog sinks accepting an
1717
`ITextFormatter`.
1818

19-
### Filtering
19+
### Filtering example
2020

2121
_Serilog.Expressions_ adds `ByExcluding()` and `ByIncludingOnly()`
2222
overloads to the `Filter` configuration object that accept filter
@@ -70,12 +70,49 @@ this is written as:
7070
</appSettings>
7171
```
7272

73-
### Enriching
73+
## Supported configuration APIs
7474

75-
### Formatting
75+
_Serilog.Expressions_ adds a number of expression-based overloads and helper methods to the Serilog configuration syntax:
76+
77+
* `Filter.ByExcluding()`, `Filter.ByIncludingOnly()` - use an expression to filter events passing through the Serilog pipeline
78+
* `WriteTo.Conditional()` - use an expression to select the events passed to a particular sink
79+
* `Enrich.When()` - conditionally enable an enricher when events match an expression
80+
* `Enrich.WithComputed()` - add or modify event properties using an expression
81+
82+
## Formatting
83+
84+
_Serilog.Expressions_ includes the `OutputTemplate` class for text formatting. `OutputTemplate` implements `ITextFormatter`, so
85+
it works with any text-based Serilog sink:
86+
87+
```csharp
88+
Log.Logger = new LoggerConfiguration()
89+
.WriteTo.Console(new OutputTemplate(
90+
"[{@t:HH:mm:ss} {@l:u3} ({SourceContext})] {@m} (first item is {Items[0]})\n{@x}"))
91+
.CreateLogger();
92+
```
93+
94+
Note the use of `{Items[0]}`: "holes" in expression-based output templates can include arbitrary expressions.
7695

7796
## Language reference
7897

98+
### Built-in properties
99+
100+
The following properties are available in expressions:
101+
102+
* All first-class properties of the event; no special syntax: `SourceContext` and `Items` are used in the formatting example above
103+
* `@t` - the event's timestamp, as a `DateTimeOffset`
104+
* `@m` - the rendered message
105+
* `@mt` - the raw message template
106+
* `@l` - the event's level, as a `LogEventLevel`
107+
* `@x` - the exception associated with the event, if any, as an `Exception`
108+
* `@p` - a dictionary containing all first-class properties; this supports properties with non-identifier names, for example `@p['snake-case-name']`
109+
110+
### Data types
111+
112+
### Functions
113+
114+
### String manipulation
115+
79116
## Working with the raw API
80117

81118
The package provides the class `SerilogExpression` in the `Serilog.Expressions` namespace

0 commit comments

Comments
 (0)