feat: 添加日志组件
This commit is contained in:
@@ -222,7 +222,7 @@ namespace Yi.Framework.SqlSugarCore
|
||||
{
|
||||
if (Options.EnabledSqlLog)
|
||||
{
|
||||
Logger.CreateLogger<SqlSugarDbContext>().LogDebug(UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
|
||||
Logger.CreateLogger<SqlSugarDbContext>().LogDebug("SQL执行:"+UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,15 +3,24 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Volo.Abp.Auditing;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Yi.Framework.Core.Helper;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.SqlSugarCore
|
||||
{
|
||||
public class SqlSugarLogAuditingStore : IAuditingStore, ISingletonDependency
|
||||
{
|
||||
private readonly ILogger<SqlSugarLogAuditingStore> _logger;
|
||||
public SqlSugarLogAuditingStore(ILogger<SqlSugarLogAuditingStore> logger, ISqlSugarDbContext sqlSugarDbContext)
|
||||
{
|
||||
_logger= logger;
|
||||
}
|
||||
public Task SaveAsync(AuditLogInfo auditInfo)
|
||||
{
|
||||
_logger.LogDebug(JsonHelper.ObjToStr(auditInfo, "yyyy-MM-dd HH:mm:ss"));
|
||||
//Console.WriteLine(auditInfo.ExecutionTime);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@ using Volo.Abp.BackgroundWorkers.Quartz;
|
||||
|
||||
namespace Yi.Framework.Rbac.Application.Jobs
|
||||
{
|
||||
public class TestJob : QuartzBackgroundWorkerBase
|
||||
{
|
||||
public TestJob()
|
||||
{
|
||||
JobDetail = JobBuilder.Create<TestJob>().WithIdentity(nameof(TestJob)).Build();
|
||||
Trigger = TriggerBuilder.Create().WithIdentity(nameof(TestJob)).WithCronSchedule("* * * * * ? *").Build();
|
||||
}
|
||||
public override Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
Console.WriteLine("你好,世界");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
//public class TestJob : QuartzBackgroundWorkerBase
|
||||
//{
|
||||
// public TestJob()
|
||||
// {
|
||||
// JobDetail = JobBuilder.Create<TestJob>().WithIdentity(nameof(TestJob)).Build();
|
||||
// Trigger = TriggerBuilder.Create().WithIdentity(nameof(TestJob)).WithCronSchedule("* * * * * ? *").Build();
|
||||
// }
|
||||
// public override Task Execute(IJobExecutionContext context)
|
||||
// {
|
||||
// Console.WriteLine("你好,世界");
|
||||
// return Task.CompletedTask;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace Yi.Framework.Rbac.Application
|
||||
|
||||
public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context)
|
||||
{
|
||||
//await context.AddBackgroundWorkerAsync<TestJob>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,7 @@ namespace Yi.Abp.SqlSugarCore
|
||||
|
||||
protected override void OnLogExecuting(string sql, SugarParameter[] pars)
|
||||
{
|
||||
//获取原生SQL推荐 5.1.4.63 性能OK
|
||||
//UtilMethods.GetNativeSql(sql,pars)
|
||||
|
||||
//获取无参数化SQL 影响性能只适合调试
|
||||
this.Logger.CreateLogger<YiDbContext>().LogInformation(UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
|
||||
base.OnLogExecuting(sql, pars);
|
||||
}
|
||||
|
||||
protected override void OnLogExecuted(string sql, SugarParameter[] pars)
|
||||
|
||||
1681
Yi.Abp.Net8/src/Yi.Abp.Web/Logs/logs20231212.txt
Normal file
1681
Yi.Abp.Net8/src/Yi.Abp.Web/Logs/logs20231212.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,30 @@
|
||||
using Serilog;
|
||||
using Yi.Abp.Web;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.UseUrls(builder.Configuration["App:SelfUrl"]);
|
||||
builder.Host.UseAutofac();
|
||||
await builder.Services.AddApplicationAsync<YiAbpWebModule>();
|
||||
var app = builder.Build();
|
||||
await app.InitializeApplicationAsync();
|
||||
await app.RunAsync();
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.WriteTo.Async(c => c.File("Logs/logs.txt", rollingInterval: RollingInterval.Day))
|
||||
.WriteTo.Async(c => c.Console())
|
||||
.CreateLogger();
|
||||
|
||||
try
|
||||
{
|
||||
Log.Information("Yi<59><69><EFBFBD><EFBFBD>-Abp.vNext<78><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.UseUrls(builder.Configuration["App:SelfUrl"]);
|
||||
builder.Host.UseAutofac();
|
||||
builder.Host.UseSerilog();
|
||||
await builder.Services.AddApplicationAsync<YiAbpWebModule>();
|
||||
var app = builder.Build();
|
||||
await app.InitializeApplicationAsync();
|
||||
await app.RunAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex, "Yi<59><69><EFBFBD><EFBFBD>-Abp.vNext<78><74><EFBFBD><EFBFBD>ը<EFBFBD><D5A8>");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
@@ -10,6 +10,8 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.14" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.12" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="7.4.2" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="7.4.1" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="7.4.1" />
|
||||
|
||||
@@ -65,10 +65,7 @@ namespace Yi.Abp.Web
|
||||
{
|
||||
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
||||
});
|
||||
Configure<AbpJsonOptions>(options =>
|
||||
{
|
||||
options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss";
|
||||
});
|
||||
|
||||
Configure<AbpAntiForgeryOptions>(options =>
|
||||
{
|
||||
options.AutoValidate = false;
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user