Serilog

Serilog是.NET开源结构化日志类库

开源地址:https://github.com/serilog

官网:https://serilog.net/

Serilog能做什么:

  1. 记录代码中的BUG和错误
  2. 更快的找到生产环境中的问题
  3. 深入的了解系统运行表现

想对Serilog多点了解,请查阅[译]Serilog Tutorial,翻译的很棒。

重现Error出现的场景

在自己的项目中使用Serilog并使用MongoDB记录日志,需要nuget引用 SerilogSerilog.Sinks.MongoDB

我引用的是 Serilog 2.7.1Serilog.Sinks.MongoDB 3.1.0

Serilog.Sinks.MongoDB 3.1.0 依赖的是的MongoDB组件库是 MongoDB.Driver 2.3.0MongoDB.Driver.Core 2.3.0MongoDB.Bson 2.3.0,所以当nuget引用Serilog.Sinks.MongoDB 3.1.0 自然会引用 MongoDB.Driver 2.3.0MongoDB.Driver.Core 2.3.0MongoDB.Bson 2.3.0

在记录MongoDB日志时报错,内容如下

The GuidRepresentation for the reader is CSharpLegacy, which requires the binary sub type to be UuidLegacy, not UuidStandard

解决方案

程序员google大法,找到同样的错误。点击查看:

The GuidRepresentation for the reader is CSharpLegacy, which requires the binary sub type to be UuidLegacy, not UuidStandard

文中给了三种解决方案:

1、修改全局配置 BsonDefaults.GuidRepresentation

BsonDefaults.GuidRepresentation = GuidRepresentation.Standard;

2、当你创建collection时指定配置

MongoDatabase db = ???;
string collectionName = ???;
var collectionSettings = new MongoCollectionSettings {
GuidRepresentation = GuidRepresentation.Standard
};
var collection = db.GetCollection<BsonDocument>(collectionName, collectionSettings);

3、更新驱动

原文如下

Solution 3.update to .NET Driver Version 2.5.x

.NET Driver Version 2.5.0 Release Notes say below:

The main new feature of 2.5.0 is support for the new features of the 3.6 version of the server:

...

Improved support for reading and writing UUIDs in BsonBinary subtype 4 format

解决方案1和2都有点瞎啊,推测要改Serilog.Sinks.MongoDB的源码。自然先按照最简单的开始尝试,更新MongoDB驱动。

我的尝试解决方案:MongoDB.Driver 2.3.0MongoDB.Driver.Core 2.3.0MongoDB.Bson 2.3.0 统统更新至2.7.0版本(注:当前最新的稳定版本)。然后,嘣!问题解决!

Serilog记录MongoDB日志报错:requires the binary sub type to be UuidLegacy, not UuidStandard的更多相关文章

  1. The GuidRepresentation for the reader is CSharpLegacy, which requires the binary sub type to be Uuid

    使用客户端链接MongoDb报错 The GuidRepresentation for the reader is CSharpLegacy, which requires the binary su ...

  2. Django日志记录详细的报错信息

    当服务器500错误的时候,普通日志只会记录一行500的request信息,并不会记录详细的报错定位 [ERROR] 2019-06-12 15:07:03,597 "GET /api/v1/ ...

  3. 【zabbix监控问题】记录zabbix控制面板报错及日志报错的解决方法

    问题1: 上图是我已经解决了的截图.在百度查询的资料中,说是把zabbix_agentd.conf文件中server监听的主机127.0.0.1去掉,但是我去掉之后问题仍然没有解决,最后在这篇博客上发 ...

  4. 11gR2数据库日志报错:Fatal NI connect error 12170、

    11gR2数据库日志报错:Fatal NI connect error 12170.TNS-12535.TNS-00505 [问题点数:100分,结帖人MarkIII]             不显示 ...

  5. Oracle添加记录的时候报错:违反完整性约束,未找到父项关键字

    今天需要向一个没有接触过的一个Oracle数据库中添加一条记录,执行报错: 分析: 报错的根本原因:未找到父项关键字的原因是因为你在保存对象的时候缺失关联对象. 问题的解决思路:先保存关联对象后再保存 ...

  6. zabbix客户端日志报错no active checks on server [192.168.3.108:10051]: host [192.168.3.108] not found

    zabbix客户端日志报错: 45647:20160808:220507.717 no active checks on server [192.168.3.108:10051]: host [192 ...

  7. 记一次rsync日志报错directory has vanished

    中午两点的时候邮件告知rsync同部svn源库失败,看rsync日志报错显示如上,当时还在上课,没在公司,怀疑是不是有人动了svn的版本库,后来询问同事并通过vpn登录服务器上查看版本库是正常的,也没 ...

  8. 【docker】【redis】2.docker上设置redis集群---Redis Cluster部署【集群服务】【解决在docker中redis启动后,状态为Restarting,日志报错:Configured to not listen anywhere, exiting.问题】【Waiting for the cluster to join...问题】

    参考地址:https://www.cnblogs.com/zhoujinyi/p/6477133.html https://www.cnblogs.com/cxbhakim/p/9151720.htm ...

  9. 树莓派 mongodb 安装&报错处理

    树莓派 mongodb 安装&报错处理 编译过的源码下载地址: http://files.cnblogs.com/files/xueshanshan/mongodb-rpi.zip addus ...

随机推荐

  1. linux 硬盘

    df -hT 查看格式 各种文件 mount命令 可以挂载那些块设备:光盘.磁盘分区.U盘 光盘:文件系统:iso9660 iso文件文件系统:iso9660 iso文件可以进行挂载的 mount c ...

  2. Mybatis in 查询

    1.先创建一个传参的工具类 import java.util.HashMap; /** * * ClassName: DataMap * @Description: 封装Map, * @date 20 ...

  3. dubbo环境搭建

    主要是通过使用tomcat和使用main方法进行发布服务 参考文章: http://blog.csdn.net/aixiaoyang168/article/details/51362675 http: ...

  4. React 和 Redux 结合 1

    React依赖: "devDependencies": { "babel-core": "^6.26.0", "babel-loa ...

  5. Spring源码追踪1——doGetBean(为什么org.springframework.data.redis.core.RedisTemplate的实例可以注入为ListOperations)

    类org.springframework.beans.factory.support.AbstractBeanFactory方法T doGetBean(final String name, final ...

  6. Javascript高级编程学习笔记(64)—— 事件(8)键盘与文本事件

    键盘与文本事件 用户在使用键盘时会触发键盘事件 “DOM2级事件”最初规定了键盘事件,但是最后在定稿时又删除了相应内容 所以键盘事件被放入了DOM3级事件的规范中 总的来说有三个键盘事件: keydo ...

  7. Kali学习笔记16:Nmap详细讲解

    在前面十五篇博客中,几乎每一篇都有介绍Nmap,这里系统地介绍下每个参数: 注意:区分每个参数的大小写 -iL:列好的IP放在一个文本里面,可以直接扫描这个文本 用法:namp -iL <文本名 ...

  8. 在Ubuntu 18.04中安装pyenv(Python多版本管理工具)

    最近正在重头梳理Python的基础知识,为了更好地使用Python进行开发,防止发生版本混乱(不同的第三方库有可能因为Python版本不兼容而报错),所以需要使用pyenv进行版本管理. *** 通常 ...

  9. Java-redis-雪崩优化

    缓存失效的时候如下图: 解决办法"使用互斥锁(mutex key):下面是核心伪代码 v = memcache.get(key); if (v == null) { if (memcache ...

  10. LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Sun Jan 13 17:59:19 CST 2019]; root of context hierarch

    在运行项目时出现了:LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via ...