InuLogs 1.0.8

dotnet add package InuLogs --version 1.0.8
                    
NuGet\Install-Package InuLogs -Version 1.0.8
                    
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="InuLogs" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="InuLogs" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="InuLogs" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add InuLogs --version 1.0.8
                    
#r "nuget: InuLogs, 1.0.8"
                    
#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.
#:package InuLogs@1.0.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=InuLogs&version=1.0.8
                    
Install as a Cake Addin
#tool nuget:?package=InuLogs&version=1.0.8
                    
Install as a Cake Tool

InuLogs

介绍

InuLogs 是一个专为 ASP.Net Core 网站应用程序和 API 设计的 HTTP 请求和异常记录器与查看器组件。它为开发人员提供了实时记录和查看网站应用程序中 HTTP 请求及其响应、以及运行时捕获的异常的功能。InuLogs 默认使用MongoDB 作为服务器端数据库,但也支持外部数据库,如 OraclePostgreSQLMySQLMSSQL。此外,该组件还提供了在页面上重试 HTTP 请求的功能,并允许根据关键词检索响应内容、标记返回结果的准确性。这一强大的工具有助于开发人员更高效地进行调试和问题排查。

Request & Response Viewer

特征

  • 实时 HTTP 请求、响应和异常记录器
  • 代码内消息和事件记录
  • 友好的记录器页面
  • HTTP 和异常日志的搜索选项
  • 记录器页面身份验证
  • “自动清除日志”选项
  • HTTP请求重试功能
  • 根据关键词检索响应内容是否异常功能

支持

  • .NET Core 3.1 及更高版本

安装

通过 .NET CLI 安装

dotnet add package InuLogs

通过包管理器安装

Install-Package InuLogs

用法

要使InuLogs能够监听请求,请使用InuLogs提供的InuLogs中间件。

Startup.cs 文件中添加InuLogs命名空间

using InuLogs;

Startup.cs ConfigureService()中注册InuLogs

services.AddInuLogServices();

设置清除日志选项 Optional

将在特定时间后清除日志.

注意 IsAutoClear = true 当“默认计划时间”设置为“每周”时,请覆盖如下所示的设置:

services.AddInuLogServices(opt => 
{ 
   opt.IsAutoClear = true;
   opt.ClearTimeSchedule = InuLogsAutoClearScheduleEnum.Monthly;
});

设置外部数据库记录日志(MSSQL、MySQL、PostgreSQL、Oracle 和 MongoDb) Optional

添加数据库连接字符串并选择 DbDriver 选项

services.AddInuLogServices(opt => 
{
   opt.IsAutoClear = true; 
   opt.SetExternalDbConnString = "Server=localhost;Database=testDb;User Id=postgres;Password=root;"; 
   opt.DbDriverOption = InuLogsDbDriverEnum.PostgreSql; 
});

在HTTP请求管道中添加 InuLogs 中间件 Startup.cs Configure()

Login page sample

注意 添加身份验证选项,如下所示:

此身份验证信息(用户名和密码)将用于访问日志查页面。

app.UseInuLog(opt =>
{
    opt.InuPageUsername = "admin";
    opt.InuPagePassword = "123";
});

注意 如果您的项目使用了身份验证,那么app.UseInuLog(); 应该在app.UseRouting()app.UseAuthentication()app.UseAuthorization()之后调用,按照这个顺序。

Request and Response Sample Details

可选配置: Optional
  • 黑名单:要忽略的路由、路径或端点列表(应为逗号分隔的字符串,如下所示)。
  • 序列化器:如果不是默认的,请指定使用的全局 json 序列化器/转换器的类型。
  • CorsPolicy:如果项目使用 CORS,则为策略名称。
app.UseInuLog(opt => 
{ 
   opt.InuPageUsername = "admin"; 
   opt.InuPagePassword = "Qwerty@123"; 
   //Optional
   opt.Blacklist = "Test/testPost, api/auth/login"; //Prevent logging for specified endpoints
   opt.Serializer = InuLogsSerializerEnum.Newtonsoft; //If your project use a global json converter
   opt.CorsPolicy = "MyCorsPolicy";
 });
添加 InuLogs 异常记录器 Optional

用于记录在特定 HTTP 请求期间发生的应用内异常。

Exception Sample Details

注意 在UseInuLog中间件之前添加异常日志记录器,最好将其置于中间件层次结构的顶部,以便捕获可能的早期异常。

app.UseInuLogExceptionLogger();

...

app.UseInuLog(opt => 
{ 
   opt.InuPageUsername = "admin"; 
   opt.InuPagePassword = "Qwerty@123"; 
   ...
 });

记录消息/事件

InuLogger.Log("...Test Log...");
InuLogger.LogWarning(JsonConvert.Serialize(model));
InuLogger.LogError(res.Content, eventId: reference);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.1 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.