From 1f9c9e0c13e0999cf54e6774c1abf68456de375a Mon Sep 17 00:00:00 2001
From: CZY <2817212736@qq.com>
Date: Wed, 17 Jan 2024 17:44:08 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Serilog=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E6=97=A5=E5=BF=97;=20=E6=9B=B4=E6=94=B9=E7=A9=BAblob=E5=88=97?=
=?UTF-8?q?=E6=8F=92=E5=85=A5=E8=A7=84=E5=88=99=EF=BC=8C=E7=8E=B0=E5=9C=A8?=
=?UTF-8?q?=E5=B0=86=E6=8F=92=E5=85=A5=E7=A9=BAblob=E8=80=8C=E4=B8=8D?=
=?UTF-8?q?=E6=98=AFNULL;?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ConsoleApp2/ConsoleApp2.csproj | 1 +
ConsoleApp2/Program.cs | 8 +++++++-
ConsoleApp2/Services/MySqlDestination.cs | 2 +-
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/ConsoleApp2/ConsoleApp2.csproj b/ConsoleApp2/ConsoleApp2.csproj
index be7c309..d792e05 100644
--- a/ConsoleApp2/ConsoleApp2.csproj
+++ b/ConsoleApp2/ConsoleApp2.csproj
@@ -25,6 +25,7 @@
+
diff --git a/ConsoleApp2/Program.cs b/ConsoleApp2/Program.cs
index 0e2463c..891e5dd 100644
--- a/ConsoleApp2/Program.cs
+++ b/ConsoleApp2/Program.cs
@@ -12,6 +12,7 @@ using Microsoft.Extensions.Logging;
using MySqlConnector;
using Serilog;
using Microsoft.Extensions.Caching.Distributed;
+using Serilog.Events;
await RunProgram();
@@ -471,7 +472,12 @@ async Task RunProgram()
host.Services.AddLogging(builder =>
{
builder.ClearProviders();
- builder.AddSerilog(new LoggerConfiguration().WriteTo.Console().CreateLogger());
+ builder.AddSerilog(new LoggerConfiguration()
+ .WriteTo.Console()
+ .WriteTo.File("./log/error.log", restrictedToMinimumLevel:LogEventLevel.Error)
+ // .WriteTo.File("./log/info.log", restrictedToMinimumLevel:LogEventLevel.Information) //性能考虑暂不使用
+ .CreateLogger()
+ );
});
host.Services.AddSingleton();
diff --git a/ConsoleApp2/Services/MySqlDestination.cs b/ConsoleApp2/Services/MySqlDestination.cs
index d4f89e8..dab0df6 100644
--- a/ConsoleApp2/Services/MySqlDestination.cs
+++ b/ConsoleApp2/Services/MySqlDestination.cs
@@ -128,7 +128,7 @@ public class MySqlDestination : IDisposable, IAsyncDisposable
break;
case ColumnType.Blob:
if (string.IsNullOrEmpty(field))
- recordSb.Append("NULL");
+ recordSb.Append("''");
else recordSb.Append($"0x{field}");
break;
case ColumnType.UnDefine: