RuoVea.OmiLog
6.0.0.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package RuoVea.OmiLog --version 6.0.0.3
NuGet\Install-Package RuoVea.OmiLog -Version 6.0.0.3
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="RuoVea.OmiLog" Version="6.0.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RuoVea.OmiLog --version 6.0.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RuoVea.OmiLog, 6.0.0.3"
#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 RuoVea.OmiLog as a Cake Addin #addin nuget:?package=RuoVea.OmiLog&version=6.0.0.3 // Install RuoVea.OmiLog as a Cake Tool #tool nuget:?package=RuoVea.OmiLog&version=6.0.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RuoVea.OmiLog
介绍:
日志管理 UI界面
日志管理 平台(RuoVea.OmiLog):基于.Net5.0 、.Net6.0 、.Net7.0、.Net8.0构建的简单、跨平台的系统。 系统业务简单、代码清晰,如果您只是单纯只需简单增、删、改、查。没有多余的功能,简单扩展下基本可以满足日常需求。 支持的数据库有 MySql、SqlServer、PostgreSQL、SQLite、Oracle、Firebird(后续支持)
安装教程
Install-Package RuoVea.OmiLog
builder.Services.AddOmiLogSetup();
builder.Services.AddSqlSugarSetup();
app.UseOmiLogUI();
示例
builder.Services
.AddRestFulLogSetup<SuGarLog>()
.AddSqlSugarSetup();
builder.Services
.AddRestfulSetup<FileLog>()
.RequestActionSetup() // 注入 请求日志拦截 [执行操作日志、参数验证 ]
.ExceptionSetup()
SuGarLog
/// <summary>
///
/// </summary>
public class SuGarLog : RestFulLog, IRestFulLog
{
/// <summary>
/// 差异日志
/// </summary>
/// <param name="afterData"></param>
/// <param name="beforeData"></param>
/// <param name="parameters"></param>
/// <param name="sql"></param>
/// <param name="time"></param>
/// <param name="businessData"></param>
/// <param name="diffType"></param>
/// <param name="elapsed"></param>
public override void DiffLogString(List<DiffLogTableInfo> afterData, List<DiffLogTableInfo> beforeData, SugarParameter[] parameters, string sql, TimeSpan? time, object businessData, DiffType diffType, long elapsed)
{
SqlSugarClient sqlSugarClient = new SqlSugarClient(new ConnectionConfig
{
DbType = DbType.Sqlite,
ConnectionString = "DataSource=./database.db",
ConfigureExternalServices = new ConfigureExternalServices()
{
EntityService = (x, p) => //处理列名
{
//最好排除DTO类
p.DbColumnName = UtilMethods.ToUnderLine(p.DbColumnName);//驼峰转下划线方法
},
EntityNameService = (x, p) => //处理表名
{
//最好排除DTO类
p.DbTableName = UtilMethods.ToUnderLine(p.DbTableName);//驼峰转下划线方法
}
}
});
sqlSugarClient.Insertable(new SysLogDiff
{
AfterData = afterData?.Json2Str(),
BeforeData = beforeData?.Json2Str(),
BusinessData = beforeData?.ToString(),
DiffType = diffType.ToString(),
Elapsed = elapsed,
Sql = sql,
Parameters = parameters.Json2Str(),CreateTime=DateTime.Now
}).ExecuteCommand();
}
/// <summary>
/// 异常日志
/// </summary>
/// <param name="sql"></param>
public override void SugarErrorLogString(string sql)
{
base.SugarErrorLogString(sql);
}
/// <summary>
///
/// </summary>
/// <param name="sql"></param>
public override void SugarExecutingLogString(string sql)
{
try
{
//SqlSugarClient sqlSugarClient = new SqlSugarClient(new ConnectionConfig { DbType = DbType.Sqlite, ConnectionString = "DataSource=./database.db",
// ConfigureExternalServices = new ConfigureExternalServices()
// {
// EntityService = (x, p) => //处理列名
// {
// //最好排除DTO类
// p.DbColumnName = UtilMethods.ToUnderLine(p.DbColumnName);//驼峰转下划线方法
// },
// EntityNameService = (x, p) => //处理表名
// {
// //最好排除DTO类
// p.DbTableName = UtilMethods.ToUnderLine(p.DbTableName);//驼峰转下划线方法
// }
// }
//});
//sqlSugarClient.Insertable(new SysLogOp
//{
// Ip="127.0.0.1",
// Browser="",
// Os="wind10",
// OpTime=DateTime.Now,
// Account="1",
//}).ExecuteCommand();
}
catch (Exception ex) {
}
}
}
FileLog
public class FileLog : RestfulFilterLog
{
private readonly SugarRepository<SysLogEx> _thisRepository;
private readonly SugarRepository<SysLogOp> _sysLogOpRepository;
private readonly SugarRepository<SysLogVis> _sysLogVisRepository;
/// <summary>
///
/// </summary>
/// <param name="thisRepository"></param>
/// <param name="sysLogOpRepository"></param>
public FileLog(SugarRepository<SysLogEx> thisRepository, SugarRepository<SysLogOp> sysLogOpRepository, SugarRepository<SysLogVis> sysLogVisRepository)
{
_thisRepository = thisRepository;
_sysLogOpRepository = sysLogOpRepository;
_sysLogVisRepository = sysLogVisRepository;
}
public override void OperationLog(OperationVo operation)
{
base.OperationLog(operation);
List<string> ignoreUrls = new List<string>{ "pages", "Index" };
if (ignoreUrls.Contains( operation.ActionName))
{
_sysLogOpRepository.Insert(new SysLogOp
{
ClassName = operation.ControllerName + "/" + operation.ActionName,
Name = operation.ActionDescriptorName,
MethodName = operation.OpType.ToString(),
Success = operation.Success ?? YesOrNot.N,
Message = operation.Message,
Ip = operation.IpAddress,
Location = operation.RequestUrl,
Browser = operation.Browser,
Os = operation.Os,
Url = operation.Url,
ReqMethod = operation.RequestType,
Param = operation.Param,
Result = operation.Result,
ElapsedTime = operation.ElapsedTime ?? 0,
OpTime = operation.OperationTime ?? DateTime.Now,
Account = operation.TenantId + ":" + operation.userId + "-" + operation.Account,
});
}
if (operation.Url == "/logex/pages")
{
_sysLogVisRepository.Insert(new SysLogVis
{
Name = operation.ActionDescriptorName,
Success = operation.Success ?? YesOrNot.N,
Message = operation.Message,
Ip = operation.IpAddress,
Location = operation.RequestUrl,
Browser = operation.Browser,
Os = operation.Os,
Account = operation.TenantId + ":" + operation.userId + "-" + operation.Account,
VisType = LoginType.LOGIN,
VisTime = DateTime.Now
});
}
}
/// <summary>
///
/// </summary>
/// <param name="exception"></param>
public override void ExceptionLog(ExceptionVo exception)
{
base.ExceptionLog(exception);
_thisRepository.Insert(new SysLogEx
{
Account = exception.Account,
Name = exception.Name,
ClassName = exception.ClassName,
MethodName = exception.MethodName,
ExceptionMsg = exception.ExceptionMessage,
ExceptionSource = exception.ExceptionSource,
StackTrace = exception.StackTrace,
ParamsObj = exception.ParamsObj,
ExceptionTime = exception.ExceptionTime ?? DateTime.Now,
});
}
}
配置信息
/* 数据库链接 */
// 具体配置见SqlSugar官网(第一个为默认库不需要设置ConfigId)
"ConnectionConfigs": [
{
"DbType": "Sqlite", // MySql、SqlServer、Sqlite、Oracle、PostgreSQL、Dm、Kdbndp、Oscar、MySqlConnector、Access、OpenGauss、QuestDB、HG、ClickHouse、GBase、Odbc、Custom
"ConnectionString": "DataSource=./database.db", // 库连接字符串
"EnableInitDb": true, // 启用库表初始化
"EnableInitSeed": true, // 启用种子初始化
"EnableDiffLog": true, // 启用库表差异日志
"EnableUnderLine": true, // 启用驼峰转下划线
"IsEncrypt": true, //是否加密
"DbSecurity": "" //链接字符串解密密钥
}
// 其他数据库配置(可以配置多个)
//{
// "ConfigId": "test",
// "DbType": "Sqlite",
// "ConnectionString": "DataSource=./test.db", // 库连接字符串
// "EnableInitDb": true, // 启用库表初始化
// "EnableInitSeed": true, // 启用种子初始化
// "EnableDiffLog": false, // 启用库表差异日志
// "EnableUnderLine": false // 启用驼峰转下划线
// "IsEncrypt": true, //是否加密
// "DbSecurity": "" //链接字符串解密密钥
//}
],
"RequestLog": {
"Enabled": true,
"LogToFile": true, //记录到文件
"LogMore": true, //记录更多内容 如写入数据库 需继承重写 IRestfulFilterLog
"IgnoreApis": ""
},
"ExceptionLog": {
"Enabled": true,
"LogToFile": true,
"LogMore": true
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Magicodes.IE.Excel (>= 2.7.5.2)
- Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (>= 6.0.33)
- RuoVea.ExFilter (>= 6.0.19.2)
- RuoVea.ExSugar (>= 6.0.18.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.