函数的类型的JsonSerializationException

函数的类型的JsonSerializationException

本文介绍了带有私有构造函数的类型的JsonSerializationException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将NLog日志记录语句持久保存到我的RavenDb数据库中. LogEventInfo类代表一个日志语句,它具有一个带有私有构造函数的属性LogLevel. LogLevel的实例(信息,警告等)是通过调用私有构造函数的静态只读属性创建的.

I am persisting NLog logging statements to my RavenDb database. The LogEventInfo class, which represents a log statement, has a property, LogLevel, with a private constructor. Instances of LogLevel (Info, Warn, etc.) are created via static, readonly properties that call the private constructor.

问题是我希望从数据库中读取消息,并查询它们会引发Json.Net序列化错误:

The problem is that I wish to read the messages out of the database and querying for them is throwing a Json.Net serialization error:

如何解决该错误?可以在这里创建某种Raven索引吗?

How can I get around the error? Could creating some kind of Raven index help here?

推荐答案

我认为最简单的方法是创建一个自定义类来保存所有日志信息.

I think the easiest way to do this, is to create a custom class to hold all the log information.

这篇关于带有私有构造函数的类型的JsonSerializationException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 07:11