如何设置 SQL Server 数据库以进行语义日志记录。 是否需要提前创建用于记录信息的表? 如果是,要使用的架构是什么。
我有以下代码:
var listener = new ObservableEventListener();
string connectionString = @"Data Source=nibc2025;Initial Catalog=TreeDataBase;Integrated Security=True;User Id=sa;Password=nous@123";
listener.EnableEvents(AuditingEventSource.Log, EventLevel.LogAlways, Keywords.All);
databaseSubscription = listener.LogToSqlDatabase
(
"Test",
connectionString,
"Traces",
Buffering.DefaultBufferingInterval,
1,
Timeout.InfiniteTimeSpan, 500
);
// The following one line of code is not part of this function.
// It is just added here to show this is how I log my information.
// Inside LogInformation method I call the 'Write' method
AuditingEventSource.Log.LogInformation("sgsgg", "sgsg");
databaseSubscription.Sink.FlushAsync().Wait();
最佳答案
好吧,由于该线程在 Google 上获得关于 SQL DB 甚至 SLAB 语义日志记录的点击率最高...
创建数据库的脚本位于此处
\packages\EnterpriseLibrary.SemanticLogging.Database.1.0.1304.0\scripts
要创建 EventSource 并触发 block ,此处提供了快捷方式和快速修复解决方案的信息
http://entlib.codeplex.com/discussions/540723
问候,
关于application-blocks - 如何使用 SqlDatabaseSink 为语义日志记录应用程序 block 创建数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26606618/