You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-24Lines changed: 31 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -125,16 +125,22 @@ The following properties are available in expressions:
125
125
126
126
***All first-class properties of the event** - no special syntax: `SourceContext` and `Cart` are used in the formatting examples above
127
127
*`@t` - the event's timestamp, as a `DateTimeOffset`
128
-
*`@m` - the rendered message
128
+
*`@m` - the rendered message (Note: do not add format specifiers like `:lj` or you'll lose theme color rendering. These format specifiers are not supported as they've become the default and only option - [see the discussion here](https://github.com/serilog/serilog-expressions/issues/56#issuecomment-1146472988)
129
129
*`@mt` - the raw message template
130
130
*`@l` - the event's level, as a `LogEventLevel`
131
131
*`@x` - the exception associated with the event, if any, as an `Exception`
132
132
*`@p` - a dictionary containing all first-class properties; this supports properties with non-identifier names, for example `@p['snake-case-name']`
133
133
*`@i` - event id; a 32-bit numeric hash of the event's message template
134
134
*`@r` - renderings; if any tokens in the message template include .NET-specific formatting, an array of rendered values for each such token
135
+
*`@tr` - trace id; The id of the trace that was active when the event was created, if any
136
+
*`@sp` - span id; The id of the span that was active when the event was created, if any
135
137
136
138
The built-in properties mirror those available in the CLEF format.
137
139
140
+
The exception property `@x` is treated as a scalar and will appear as a string when formatted into text. The properties of
141
+
the underlying `Exception` object can be accessed using `Inspect()`, for example `Inspect(@x).Message`, and the type of the
142
+
exception retrieved using `TypeOf(@x)`.
143
+
138
144
### Literals
139
145
140
146
| Data type | Description | Examples |
@@ -181,29 +187,30 @@ calling a function will be undefined if:
181
187
* any argument is undefined, or
182
188
* any argument is of an incompatible type.
183
189
184
-
| Function | Description |
185
-
| :--- | :--- |
186
-
|`Coalesce(p0, p1, [..pN])`| Returns the first defined, non-null argument. |
187
-
|`Concat(s0, s1, [..sN])`| Concatenate two or more strings. |
188
-
|`Contains(s, t)`| Tests whether the string `s` contains the substring `t`. |
189
-
|`ElementAt(x, i)`| Retrieves a property of `x` by name `i`, or array element of `x` by numeric index `i`. |
190
-
|`EndsWith(s, t)`| Tests whether the string `s` ends with substring `t`. |
191
-
|`IndexOf(s, t)`| Returns the first index of substring `t` in string `s`, or -1 if the substring does not appear. |
192
-
|`IndexOfMatch(s, p)`| Returns the index of the first match of regular expression `p` in string `s`, or -1 if the regular expression does not match. |
193
-
|`IsMatch(s, p)`| Tests whether the regular expression `p` matches within the string `s`. |
194
-
|`IsDefined(x)`| Returns `true` if the expression `x` has a value, including `null`, or `false` if `x` is undefined. |
195
-
|`LastIndexOf(s, t)`| Returns the last index of substring `t` in string `s`, or -1 if the substring does not appear. |
196
-
|`Length(x)`| Returns the length of a string or array. |
197
-
|`Now()`| Returns `DateTimeOffset.Now`. |
198
-
|`Rest([deep])`| In an `ExpressionTemplate`, returns an object containing the first-class event properties not otherwise referenced in the template. If `deep` is `true`, also excludes properties referenced in the event's message template. |
199
-
|`Round(n, m)`| Round the number `n` to `m` decimal places. |
200
-
|`StartsWith(s, t)`| Tests whether the string `s` starts with substring `t`. |
201
-
|`Substring(s, start, [length])`| Return the substring of string `s` from `start` to the end of the string, or of `length` characters, if this argument is supplied. |
202
-
|`TagOf(o)`| Returns the `TypeTag` field of a captured object (i.e. where `TypeOf(x)` is `'object'`). |
203
-
|`ToString(x, [format])`| Convert `x` to a string, applying the format string `format` if `x` is `IFormattable`. |
204
-
|`TypeOf(x)`| Returns a string describing the type of expression `x`: a .NET type name if `x` is scalar and non-null, or, `'array'`, `'object'`, `'dictionary'`, `'null'`, or `'undefined'`. |
205
-
|`Undefined()`| Explicitly mark an undefined value. |
206
-
|`UtcDateTime(x)`| Convert a `DateTime` or `DateTimeOffset` into a UTC `DateTime`. |
|`Coalesce(p0, p1, [..pN])`| Returns the first defined, non-null argument. |
193
+
|`Concat(s0, s1, [..sN])`| Concatenate two or more strings. |
194
+
|`Contains(s, t)`| Tests whether the string `s` contains the substring `t`. |
195
+
|`ElementAt(x, i)`| Retrieves a property of `x` by name `i`, or array element of `x` by numeric index `i`. |
196
+
|`EndsWith(s, t)`| Tests whether the string `s` ends with substring `t`. |
197
+
|`IndexOf(s, t)`| Returns the first index of substring `t` in string `s`, or -1 if the substring does not appear. |
198
+
|`IndexOfMatch(s, p)`| Returns the index of the first match of regular expression `p` in string `s`, or -1 if the regular expression does not match. |
199
+
|`Inspect(o, [deep])`| Read properties from an object captured as the scalar value `o`. |
200
+
|`IsMatch(s, p)`| Tests whether the regular expression `p` matches within the string `s`. |
201
+
|`IsDefined(x)`| Returns `true` if the expression `x` has a value, including `null`, or `false` if `x` is undefined. |
202
+
|`LastIndexOf(s, t)`| Returns the last index of substring `t` in string `s`, or -1 if the substring does not appear. |
203
+
|`Length(x)`| Returns the length of a string or array. |
204
+
|`Now()`| Returns `DateTimeOffset.Now`. |
205
+
|`Rest([deep])`| In an `ExpressionTemplate`, returns an object containing the first-class event properties not otherwise referenced in the template. If `deep` is `true`, also excludes properties referenced in the event's message template. |
206
+
|`Round(n, m)`| Round the number `n` to `m` decimal places. |
207
+
|`StartsWith(s, t)`| Tests whether the string `s` starts with substring `t`. |
208
+
|`Substring(s, start, [length])`| Return the substring of string `s` from `start` to the end of the string, or of `length` characters, if this argument is supplied. |
209
+
|`TagOf(o)`| Returns the `TypeTag` field of a captured object (i.e. where `TypeOf(x)` is `'object'`). |
210
+
|`ToString(x, [format])`| Convert `x` to a string, applying the format string `format` if `x` is `IFormattable`. |
211
+
|`TypeOf(x)`| Returns a string describing the type of expression `x`: a .NET type name if `x` is scalar and non-null, or, `'array'`, `'object'`, `'dictionary'`, `'null'`, or `'undefined'`. |
212
+
|`Undefined()`| Explicitly mark an undefined value. |
213
+
|`UtcDateTime(x)`| Convert a `DateTime` or `DateTimeOffset` into a UTC `DateTime`. |
207
214
208
215
Functions that compare text accept an optional postfix `ci` modifier to select case-insensitive comparisons:
0 commit comments