1- using  MongoDB . Bson . Serialization . Attributes ; 
1+ using  MongoDB . Bson ; 
2+ using  MongoDB . Bson . Serialization . Attributes ; 
23using  Newtonsoft . Json ; 
34using  Serilog . Ui . Core ; 
45using  System ; 
89namespace  Serilog . Ui . MongoDbProvider 
910{ 
1011    [ BsonIgnoreExtraElements ] 
12+     [ BsonDiscriminator ( RootClass  =  true ) ] 
1113    public  class  MongoDbLogModel 
1214    { 
1315        [ BsonIgnore ] 
@@ -23,8 +25,10 @@ public class MongoDbLogModel
2325        [ BsonDateTimeOptions ( Kind  =  DateTimeKind . Local ) ] 
2426        public  DateTime  UtcTimeStamp  {  get ;  set ;  } 
2527
26-         public  dynamic  Exception  {  get ;  set ;  } 
28+         [ BsonElement ( "Exception" ) ] 
29+         public  BsonDocument  Exception  {  get ;  set ;  } 
2730
31+         [ BsonElement ( "Properties" ) ] 
2832        public  object  Properties  {  get ;  set ;  } 
2933
3034        internal  LogModel  ToLogModel ( ) 
@@ -36,20 +40,18 @@ internal LogModel ToLogModel()
3640                Message  =  RenderedMessage , 
3741                Timestamp  =  Timestamp  ??  UtcTimeStamp , 
3842                Exception  =  GetException ( Exception ) , 
39-                 Properties  =  Newtonsoft . Json . JsonConvert . SerializeObject ( Properties ) , 
43+                 Properties  =  JsonConvert . SerializeObject ( Properties ) , 
4044                PropertyType  =  "json" 
4145            } ; 
4246        } 
4347
44-         private  object  GetException ( dynamic  exception ) 
48+         private  string  GetException ( object  exception ) 
4549        { 
46-             if  ( exception  ==  null  ||  IsPropertyExist ( Exception ,  "_csharpnull" ) ) 
50+             if  ( exception  ==  null  ||  IsPropertyExist ( exception ,  "_csharpnull" ) ) 
4751                return  null ; 
4852
49-             if  ( exception  is  string ) 
50-                 return  exception ; 
51- 
52-             return  Newtonsoft . Json . JsonConvert . SerializeObject ( Exception ,  Formatting . Indented ) ; 
53+             var  str  =  exception . ToJson ( ) ; 
54+             return  str ; 
5355        } 
5456
5557        private  bool  IsPropertyExist ( dynamic  obj ,  string  name ) 
0 commit comments