EasilyNET.Mongo.ConsoleDebug 3.24.926.182

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasilyNET.Mongo.ConsoleDebug --version 3.24.926.182                
NuGet\Install-Package EasilyNET.Mongo.ConsoleDebug -Version 3.24.926.182                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EasilyNET.Mongo.ConsoleDebug" Version="3.24.926.182" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasilyNET.Mongo.ConsoleDebug --version 3.24.926.182                
#r "nuget: EasilyNET.Mongo.ConsoleDebug, 3.24.926.182"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EasilyNET.Mongo.ConsoleDebug as a Cake Addin
#addin nuget:?package=EasilyNET.Mongo.ConsoleDebug&version=3.24.926.182

// Install EasilyNET.Mongo.ConsoleDebug as a Cake Tool
#tool nuget:?package=EasilyNET.Mongo.ConsoleDebug&version=3.24.926.182                

EasilyNET.Mongo.ConsoleDebug

常使用 EF 的小伙伴就应该能够知道,可以让 EF 生产的 SQL 语句输出到控制台,在开发的时候非常方便调试.<br/> 而 MongoDB 却没有这样的功能,所以产生了这个库,虽然不完美,但是能够解决一些开发过程中不方便排查问题的情况.

  • 最终效果类似如下:
 ╭───────────────────────────────Command────────────────────────────────╮╭──────────────────Calendar──────────────────╮
 │ {                                                                    ││                2023 August                 │
 │   "insert" : "mongo.test",                                           ││ ┌─────┬─────┬─────┬─────┬─────┬─────┬────┐ │
 │   "ordered" : true,                                                  ││ │ Sun │ Mon │ Tue │ Wed │ Thu │ Fri │ S… │ │
 │   "$db" : "test1",                                                   ││ ├─────┼─────┼─────┼─────┼─────┼─────┼────┤ │
 │   "lsid" : {                                                         ││ │     │     │ 1   │ 2   │ 3   │ 4   │ 5  │ │
 │     "id" : CSUUID("f12dd90d-2f58-4655-9bf2-cbce2d9bd2c4")            ││ │ 6   │ 7   │ 8   │ 9   │ 10  │ 11  │ 12 │ │
 │   },                                                                 ││ │ 13  │ 14  │ 15  │ 16  │ 17  │ 18  │ 19 │ │
 │   "documents" : [{                                                   ││ │ 20  │ 21  │ 22  │ 23* │ 24  │ 25  │ 26 │ │
 │       "_id" : ObjectId("64e57f266a1a63e69c52b9cb"),                  ││ │ 27  │ 28  │ 29  │ 30  │ 31  │     │    │ │
 │       "dateTime" : ISODate("2023-08-23T03:38:14.121Z"),              ││ │     │     │     │     │     │     │    │ │
 │       "timeSpan" : "00:00:50",                                       ││ └─────┴─────┴─────┴─────┴─────┴─────┴────┘ │
 │       "dateOnly" : "2023-08-23",                                     │╰────────────────────────────────────────────╯
 │       "timeOnly" : "11:38:14",                                       │╭────────────────────Info────────────────────╮
 │       "nullableDateOnly" : "2023-08-23",                             ││ {                                          │
 │       "nullableTimeOnly" : null                                      ││    "RequestId": 86,                        │
 │     }]                                                               ││    "Timestamp": "2023-08-23 03:38:14",     │
 │ }                                                                    ││    "Method": "insert",                     │
 │                                                                      ││    "DatabaseName": "test1",                │
 │                                                                      ││    "CollectionName": "mongo.test",         │
 │                                                                      ││    "ConnectionInfo": {                     │
 │                                                                      ││       "ClusterId": 1,                      │
 │                                                                      ││       "EndPoint": "127.0.0.1:27018"        │
 │                                                                      ││    }                                       │
 │                                                                      ││ }                                          │
 │                                                                      │╰────────────────────────────────────────────╯
 │                                                                      │╭───────────────Request Status───────────────╮
 │                                                                      ││ ┌───────────┬────────────────┬───────────┐ │
 │                                                                      ││ │ RequestId │      Time      │  Status   │ │
 │                                                                      ││ ├───────────┼────────────────┼───────────┤ │
 │                                                                      ││ │    86     │ 11:38:14.12640 │ Succeeded │ │
 │                                                                      ││ └───────────┴────────────────┴───────────┘ │
 │                                                                      │╰────────────────────────────────────────────╯
 │                                                                      │╭───────────────────NiuNiu───────────────────╮
 │                                                                      ││   --------------------------------------   │
 │                                                                      ││ /     Only two things are infinite,      \ │
 │                                                                      ││ \   the universe and human stupidity.    / │
 │                                                                      ││   --------------------------------------   │
 │                                                                      ││              ^__^     O   ^__^             │
 │                                                                      ││      _______/(oo)      o  (oo)\_______     │
 │                                                                      ││  /\/(       /(__)         (__)\       )\/\ │
 │                                                                      ││     ||w----||                 ||----w||    │
 │                                                                      ││     ||     ||                 ||     ||    │
 │                                                                      ││ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ │
 ╰──────────────────────────────────────────────────────────────────────╯╰────────────────────────────────────────────╯

使用方法

  • 使用默认值配置
var clientSettings = MongoClientSettings.FromUrl(mongoUrl);
clientSettings.ClusterConfigurator = cb => cb.Subscribe(new ActivityEventSubscriber());
var mongoClient = new MongoClient(clientSettings);
  • 使用集合名称进行过滤
var clientSettings = MongoClientSettings.FromUrl(mongoUrl);
// 定义需要输出的集合
HashSet<string> CommandsWithCollectionName = new()
{
    "mongo.test"
};
var options = new InstrumentationOptions()
{
    Enable = true,
    ShouldStartCollection = coll => CommandsWithCollectionName.Contains(coll)
};
clientSettings.ClusterConfigurator = cb => cb.Subscribe(new ActivityEventSubscriber(options));
var mongoClient = new MongoClient(clientSettings);
Seilog 配置例子
// 添加Serilog配置
builder.Host.UseSerilog((hbc, lc) =>
{
    const LogEventLevel logLevel = LogEventLevel.Information;
    lc.ReadFrom.Configuration(hbc.Configuration)
          .MinimumLevel.Override("Microsoft", logLevel)
          .MinimumLevel.Override("System", logLevel)
          .Enrich.FromLogContext()
          .WriteTo.Async(wt =>
          {
              wt.Debug();
              // 输出到 Spectre.Console
              wt.SpectreConsole();
          });
});

同时参考MongoDB.Driver.Core.Extensions.DiagnosticSources

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.25.1.1 52 2 days ago
3.24.1224.141 47 11 days ago
3.24.1216.116 56 19 days ago
3.24.1206.100 57 a month ago
3.24.1205.171 61 a month ago
3.24.1202.150 61 a month ago
3.24.1126.231 56 a month ago
3.24.1126.172 55 a month ago
3.24.1126.114 58 a month ago
3.24.1126.104 54 a month ago
3.24.1125.181 40 a month ago
3.24.1125.104 54 a month ago
3.24.1121.183 48 a month ago
3.24.1120.183 50 a month ago
3.24.1119.31 52 2 months ago
3.24.1115.143 42 2 months ago
3.24.1113.100 57 2 months ago
3.24.1112.125 56 2 months ago
3.24.1107.140 50 2 months ago
3.24.1107.54 51 2 months ago
3.24.1107.34 49 2 months ago
3.24.1105.111 52 2 months ago
3.24.1103.31 60 2 months ago
3.24.1103 58 2 months ago
3.24.1031.135 48 2 months ago
3.24.1031.112 51 2 months ago
3.24.1031.104 49 2 months ago
3.24.1029.142 56 2 months ago
3.24.1025.30 53 2 months ago
3.24.1022.142 40 2 months ago
3.24.1018.204 108 3 months ago
3.24.1018.175 100 3 months ago
3.24.1018.166 102 3 months ago
3.24.1018.93 109 3 months ago
3.24.1017.42 57 3 months ago
3.24.1016.161 58 3 months ago
3.24.1015.231 58 3 months ago
3.24.1015.14 60 3 months ago
3.24.1012.114 57 3 months ago
3.24.1009.115 61 3 months ago
3.24.1008.160 55 3 months ago
3.24.1008.133 62 3 months ago
3.24.1007.185 56 3 months ago
3.24.1003.33 65 3 months ago
3.24.1002.162 59 3 months ago
3.24.929.143 57 3 months ago
3.24.929.141 59 3 months ago
3.24.929.131 56 3 months ago
3.24.929.122 64 3 months ago
3.24.926.184 57 3 months ago
3.24.926.182 59 3 months ago
3.24.926.175 59 3 months ago
3.24.924.160 57 3 months ago
3.24.924.133 67 3 months ago
3.24.924.124 55 3 months ago
3.24.924.10 63 3 months ago
3.24.924.1 57 3 months ago
3.24.923.234 55 3 months ago
3.24.923.232 55 3 months ago
3.24.923.155 58 3 months ago
3.24.919.92 69 4 months ago
3.24.914.125 77 4 months ago
3.24.914.115 64 4 months ago
3.24.914.111 61 4 months ago
3.24.911.95 64 4 months ago
3.24.908.215 53 4 months ago
3.24.904.200 60 4 months ago
3.24.828.163 67 4 months ago
3.24.820.173 68 4 months ago
3.24.814.92 77 5 months ago
3.24.812.115 74 5 months ago
3.24.802.100 48 5 months ago
3.24.801.162 59 5 months ago
3.24.801.160 56 5 months ago
3.24.801.155 57 5 months ago
3.24.730.164 48 5 months ago
3.24.730.91 47 5 months ago
3.24.724.91 54 5 months ago
3.24.718.105 65 6 months ago
3.24.716.95 65 6 months ago
3.24.712.94 55 6 months ago
3.24.710.14 61 6 months ago
3.24.709.105 59 6 months ago
3.24.704.94 62 6 months ago
3.24.701.90 68 6 months ago
3.24.628.114 67 6 months ago
3.24.627.145 57 6 months ago
3.24.620.160 67 6 months ago
3.24.613.115 63 7 months ago
3.24.612.95 62 7 months ago
3.24.528.90 62 7 months ago
3.24.522.84 74 7 months ago
3.24.512.213 69 8 months ago
3.24.508.112 74 8 months ago
2.2024.428.71 64 8 months ago
2.2024.427.1128 114 8 months ago
2.2.72 141 9 months ago
2.2.71 65 9 months ago
2.2.8 106 8 months ago
2.2.6 66 9 months ago
2.2.5 79 9 months ago
2.2.4 78 9 months ago
2.2.3 81 9 months ago
2.2.2 83 9 months ago
2.2.1 77 9 months ago
2.2.0 85 10 months ago
2.1.9 83 2/21/2024
2.1.8 87 2/18/2024
2.1.7 82 2/16/2024
2.1.6 89 2/14/2024
2.1.5 89 2/14/2024
2.1.4 89 2/9/2024
2.1.3 85 2/8/2024
2.1.2 85 2/5/2024
2.1.1.2 145 12/26/2023
2.1.1.1 89 12/26/2023
2.1.1 91 12/25/2023
2.1.0 106 12/17/2023
2.0.11 108 12/6/2023
2.0.1 105 11/15/2023
2.0.0 86 11/14/2023
1.9.1 108 11/1/2023
1.9.0 94 10/19/2023
1.9.0-preview2 86 10/12/2023
1.9.0-preview1 74 10/12/2023
1.8.9 102 10/11/2023
1.8.8 102 10/11/2023
1.8.7-rc2 82 9/21/2023
1.8.7-rc1 83 9/12/2023
1.8.6 124 8/31/2023
1.8.5 99 8/25/2023
1.8.4 100 8/24/2023
1.8.3 106 8/23/2023
1.8.2 165 8/22/2023
1.8.1 96 8/18/2023
1.8.0 589 8/15/2023
1.7.9 577 8/11/2023
1.7.8 550 8/11/2023
1.7.7 576 8/10/2023
1.7.6 625 8/9/2023
1.7.5 533 8/9/2023
1.7.4 655 8/3/2023
1.7.3 600 8/1/2023
1.7.2 639 7/31/2023
1.7.1 607 7/27/2023
1.7.0 613 7/25/2023
1.6.9 619 7/25/2023
1.6.8 634 7/24/2023
1.6.7 662 7/20/2023
1.6.6 675 7/19/2023
1.6.5 548 7/19/2023
1.6.4 632 7/17/2023
1.6.3 600 7/17/2023
1.6.2 661 7/12/2023
1.6.1 666 6/30/2023
1.6.0 632 6/26/2023
1.5.9 660 6/22/2023
1.5.8 633 6/15/2023
1.5.7.1 609 6/14/2023
1.5.7 629 6/14/2023
1.5.6.2 654 6/7/2023
1.5.6.1 628 6/7/2023
1.5.6 682 6/7/2023
1.5.5.2 596 5/26/2023
1.5.5.1 642 5/26/2023
1.5.5 670 5/26/2023
1.5.4.4 695 5/25/2023
1.5.4.3 664 5/23/2023
1.5.4.2 756 5/17/2023
1.5.4.1 668 5/16/2023
1.5.4 718 5/11/2023
1.5.3 660 5/11/2023
1.5.2 661 5/10/2023
1.5.1 628 5/10/2023
1.5.0 709 5/6/2023
1.4.0 704 5/5/2023
1.3.9 722 4/23/2023
1.3.8.6 711 4/23/2023
1.3.8.5 613 4/21/2023
1.3.8.1 737 4/12/2023
1.3.8 727 4/11/2023
1.3.7 699 4/9/2023
1.3.6.3 786 4/1/2023
1.3.6.2 702 3/31/2023
1.3.6.1 745 3/31/2023
1.3.6 730 3/31/2023
1.3.5 710 3/30/2023
1.3.4.1 800 3/29/2023
1.3.4 669 3/28/2023
1.3.3 651 3/28/2023
1.3.2 778 3/26/2023
1.3.1 851 3/22/2023
1.3.0 749 3/21/2023
1.2.0 672 3/21/2023
1.1.0 731 3/17/2023
1.0.9 693 3/15/2023
1.0.8 695 3/15/2023
1.0.7 693 3/15/2023
1.0.6 738 3/13/2023
1.0.5 780 3/13/2023
1.0.4 731 3/13/2023
1.0.2 789 2/26/2023
1.0.1 760 2/23/2023
1.0.0 735 2/20/2023