Skip to content

Commit 4f90292

Browse files
author
Sergey Komisarchik
committed
updated sample
1 parent 4424523 commit 4f90292

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

sample/Sample/Program.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.IO;
66

77
using Serilog.Core;
8+
using Serilog.Events;
89

910
namespace Sample
1011
{
@@ -32,4 +33,12 @@ public static void Main(string[] args)
3233
while (Console.ReadKey().KeyChar != 'q');
3334
}
3435
}
36+
37+
public class CustomFilter : ILogEventFilter
38+
{
39+
public bool IsEnabled(LogEvent logEvent)
40+
{
41+
return true;
42+
}
43+
}
3544
}

sample/Sample/appsettings.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@
2626
"Enrich": ["FromLogContext", "WithMachineName", "WithThreadId"],
2727
"Properties": {
2828
"Application": "Sample"
29-
}
29+
},
30+
"Filter": [
31+
{
32+
"Name": "ByIncludingOnly",
33+
"Args": {
34+
"expression": "Application = 'Sample'"
35+
}
36+
},
37+
{
38+
"Name": "With",
39+
"Args": {
40+
"filter": "Sample.CustomFilter, Sample"
41+
}
42+
}
43+
]
3044
}
3145
}

sample/Sample/project.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"Serilog.Sinks.Literate": "2.0.0",
1010
"Serilog.Sinks.RollingFile": "3.0.0",
1111
"Serilog.Enrichers.Environment": "2.0.0",
12-
"Serilog.Enrichers.Thread": "2.0.0"
12+
"Serilog.Enrichers.Thread": "2.0.0",
13+
"Serilog.Filters.Expressions": "1.0.0-*"
1314
},
1415
"frameworks": {
1516
"net4.6": {

0 commit comments

Comments
 (0)