@@ -11,12 +11,12 @@ Install the package from NuGet:
11
11
dotnet add package Serilog.Expressions
12
12
```
13
13
14
- The package adds extension methods to Serilog's ` Filter ` and
14
+ The package adds extension methods to Serilog's ` Filter ` , ` WriteTo ` , and
15
15
` Enrich ` configuration objects, along with an ` OutputTemplate `
16
16
type that's compatible with Serilog sinks accepting an
17
17
` ITextFormatter ` .
18
18
19
- ### Filtering
19
+ ### Filtering example
20
20
21
21
_ Serilog.Expressions_ adds ` ByExcluding() ` and ` ByIncludingOnly() `
22
22
overloads to the ` Filter ` configuration object that accept filter
@@ -70,12 +70,49 @@ this is written as:
70
70
</appSettings >
71
71
```
72
72
73
- ### Enriching
73
+ ## Supported configuration APIs
74
74
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.
76
95
77
96
## Language reference
78
97
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
+
79
116
## Working with the raw API
80
117
81
118
The package provides the class ` SerilogExpression ` in the ` Serilog.Expressions ` namespace
0 commit comments