File tree Expand file tree Collapse file tree 3 files changed +12
-13
lines changed
src/Serilog.Expressions/Expressions Expand file tree Collapse file tree 3 files changed +12
-13
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Sample
4
4
{
5
- public class Program
5
+ public static class Program
6
6
{
7
- public static void Main ( string [ ] args )
7
+ public static void Main ( )
8
8
{
9
- var expr = "@Level = 'Information' and AppId is not null and Items[?] like 'C%'" ;
9
+ const string expr = "@Level = 'Information' and AppId is not null and Items[?] like 'C%'" ;
10
10
11
- Log . Logger = new LoggerConfiguration ( )
11
+ using var log = new LoggerConfiguration ( )
12
12
. Enrich . WithProperty ( "AppId" , 10 )
13
13
. Filter . ByIncludingOnly ( expr )
14
- . WriteTo . LiterateConsole ( )
14
+ . WriteTo . Console ( )
15
15
. CreateLogger ( ) ;
16
16
17
- Log . Information ( "Cart contains {@Items}" , new [ ] { "Tea" , "Coffee" } ) ;
18
- Log . Warning ( "Cart contains {@Items}" , new [ ] { "Tea" , "Coffee" } ) ;
19
- Log . Information ( "Cart contains {@Items}" , new [ ] { "Apricots" } ) ;
20
- Log . Information ( "Cart contains {@Items}" , new [ ] { "Peanuts" , "Chocolate" } ) ;
21
-
22
- Log . CloseAndFlush ( ) ;
17
+ log . Information ( "Cart contains {@Items}" , new [ ] { "Tea" , "Coffee" } ) ;
18
+ log . Warning ( "Cart contains {@Items}" , new [ ] { "Tea" , "Coffee" } ) ;
19
+ log . Information ( "Cart contains {@Items}" , new [ ] { "Apricots" } ) ;
20
+ log . Information ( "Cart contains {@Items}" , new [ ] { "Peanuts" , "Chocolate" } ) ;
23
21
}
24
22
}
25
23
}
Original file line number Diff line number Diff line change 6
6
</PropertyGroup >
7
7
8
8
<ItemGroup >
9
- <PackageReference Include =" Serilog.Sinks.Literate " Version =" 2.0.0 " />
9
+ <PackageReference Include =" Serilog.Sinks.Console " Version =" 3.1.1 " />
10
10
</ItemGroup >
11
11
12
12
<ItemGroup >
Original file line number Diff line number Diff line change 15
15
using System ;
16
16
using Serilog . Core ;
17
17
using Serilog . Events ;
18
+ using Serilog . Expressions . Runtime ;
18
19
19
20
namespace Serilog . Expressions
20
21
{
@@ -81,7 +82,7 @@ public bool IsEnabled(LogEvent logEvent)
81
82
if ( filter == null )
82
83
return true ;
83
84
84
- return true . Equals ( ( filter . Item2 ( logEvent ) as ScalarValue ) ? . Value ) ;
85
+ return Coerce . True ( filter . Item2 ( logEvent ) ) ;
85
86
}
86
87
87
88
/// <inheritdoc/>
You can’t perform that action at this time.
0 commit comments