@@ -134,4 +134,36 @@ public void Emit_StructuredLogging_LogEvent(bool withActiveSpan)
134134 log . TryGetAttribute ( "property.Structure-Property" , out object ? structure ) . Should ( ) . BeTrue ( ) ;
135135 structure . Should ( ) . Be ( """[42, "42"]""" ) ;
136136 }
137+
138+ [ Fact ]
139+ public void Emit_StructuredLoggingWithException_NoBreadcrumb ( )
140+ {
141+ InMemorySentryStructuredLogger capturer = new ( ) ;
142+ _fixture . Hub . Logger . Returns ( capturer ) ;
143+ _fixture . Options . Experimental . EnableLogs = true ;
144+
145+ var sut = _fixture . GetSut ( ) ;
146+ var logger = new LoggerConfiguration ( ) . WriteTo . Sink ( sut ) . MinimumLevel . Verbose ( ) . CreateLogger ( ) ;
147+
148+ logger . Write ( LogEventLevel . Error , new Exception ( "expected message" ) , "Message" ) ;
149+
150+ _fixture . Scope . Breadcrumbs . Should ( ) . BeEmpty ( ) ;
151+ capturer . Logs . Should ( ) . ContainSingle ( ) . Which . Message . Should ( ) . Be ( "Message" ) ;
152+ }
153+
154+ [ Fact ]
155+ public void Emit_StructuredLoggingWithoutException_LeavesBreadcrumb ( )
156+ {
157+ InMemorySentryStructuredLogger capturer = new ( ) ;
158+ _fixture . Hub . Logger . Returns ( capturer ) ;
159+ _fixture . Options . Experimental . EnableLogs = true ;
160+
161+ var sut = _fixture . GetSut ( ) ;
162+ var logger = new LoggerConfiguration ( ) . WriteTo . Sink ( sut ) . MinimumLevel . Verbose ( ) . CreateLogger ( ) ;
163+
164+ logger . Write ( LogEventLevel . Error , ( Exception ? ) null , "Message" ) ;
165+
166+ _fixture . Scope . Breadcrumbs . Should ( ) . ContainSingle ( ) . Which . Message . Should ( ) . Be ( "Message" ) ;
167+ capturer . Logs . Should ( ) . ContainSingle ( ) . Which . Message . Should ( ) . Be ( "Message" ) ;
168+ }
137169}
0 commit comments