application-blocks - 如何使用 SqlDatabaseSink 为语义日志记录应用程序 block 创建数据库

标签 application-blocks logging-application-block semantic-logging

如何设置 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/

相关文章:

azure - 删除由语义日志记录创建的旧 Azure 表存储日志条目

.net - EntLib5 : Loggin application block not logging to Event Log (exception: type LogWriter cannot be constructed)- Can anyone help?

enterprise-library - 哪里可以得到政策注入(inject)的简单解释?

.net - Microsoft Security 应用程序 block 的替代方案?

c# - 记录应用程序 block 不记录到文件

enterprise-library-6 - 如何使用语义日志应用程序 block 的 SqlDatabaseSink 将有效负载存储在单独的列中

c# - EventSource/Enterprise Library Logging 缓存已删除的方法,(可能在仪器 list 中!)