【发布时间】:2020-05-07 06:27:18
【问题描述】:
Log.Information("Hello"); 没有写入表。我在自述文件中使用了基本配置here,并且接收器在第一次运行时创建了我的表。我确定我的用户具有读/写权限。
我期待Log.Information("Hello"); 向表中添加一行。
Serilog.Debugging.SelfLog.Enable(msg => Debug.WriteLine(msg));
var logDB = @"data source=xxxxxx\SQLEXPRESS;initial catalog=Eng;integrated security=False;persist security info=True;user id=xxxx;password=xxxxxxxx";
var sinkOpts = new SinkOptions();
sinkOpts.TableName = "SL24AddInLogging";
sinkOpts.AutoCreateSqlTable = true;
var columnOpts = new ColumnOptions();
columnOpts.Store.Remove(StandardColumn.Properties);
columnOpts.Store.Add(StandardColumn.LogEvent);
columnOpts.LogEvent.DataLength = 2048;
columnOpts.PrimaryKey = columnOpts.TimeStamp;
columnOpts.TimeStamp.NonClusteredIndex = true;
var log = new LoggerConfiguration()
.WriteTo.MSSqlServer(
connectionString: logDB,
sinkOptions: sinkOpts,
columnOptions: columnOpts
).CreateLogger();
我一定是做错了什么。什么?
【问题讨论】:
标签: serilog