File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
test/Serilog.Extensions.Hosting.Tests Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,39 @@ public void ReloadableLoggerRespectsMinimumLevelOverrides()
6969 Assert . Equal ( 3 , emittedEvents . Count ) ;
7070 Assert . Equal ( 2 , emittedEvents . Count ( le => le . Level == LogEventLevel . Warning ) ) ;
7171 }
72+
73+ [ Fact ]
74+ public void ReloadableLoggersRecordEnrichment ( )
75+ {
76+ var emittedEvents = new List < LogEvent > ( ) ;
77+
78+ var logger = new LoggerConfiguration ( )
79+ . WriteTo . Sink ( new ListSink ( emittedEvents ) )
80+ . CreateBootstrapLogger ( ) ;
81+
82+ var outer = logger
83+ . ForContext ( "A" , new object ( ) ) ;
84+ var inner = outer . ForContext ( "B" , "test" ) ;
85+
86+ inner . Information ( "First" ) ;
87+
88+ logger . Reload ( lc => lc . WriteTo . Sink ( new ListSink ( emittedEvents ) ) ) ;
89+
90+ inner . Information ( "Second" ) ;
91+
92+ logger . Freeze ( ) ;
93+
94+ inner . Information ( "Third" ) ;
95+
96+ outer . ForContext ( "B" , "test" ) . Information ( "Fourth" ) ;
97+
98+ logger . ForContext ( "A" , new object ( ) )
99+ . ForContext ( "B" , "test" )
100+ . Information ( "Fifth" ) ;
101+
102+ Assert . Equal ( 5 , emittedEvents . Count ) ;
103+ Assert . All ( emittedEvents , e => Assert . Equal ( 2 , e . Properties . Count ) ) ;
104+ }
72105 }
73106}
74107
You can’t perform that action at this time.
0 commit comments