enterprise-library-5


DB logging using Fluent Interface


I'm using Enterprise library 5.0. Using fluent interface I was able to configure Trace Listners for File based and Event based logging. Is there any way I can configure it for Database listner. My idea is not to use any external configuration file specific to Logging configuration.
I used the following, I'm able to log in a flatFile, Event viewer. When I try to log using DBListner, I'm not getting any error message but the message also is not getting logged. Can anyone shed some light?
.SendTo.RollingFile("Flat File Trace Listener")
.ToFile("Trace.log")
.WithHeader("----------------------")
.FormatWith(new FormatterBuilder()
.TextFormatterNamed("Text Formatter")
.UsingTemplate("Timestamp: {timestamp}{newline}Message: {message}{newline}Category: {category}{newline}Priority: {priority}{newline}EventId: {eventid}{newline}Severity: {severity}{newline}Title:{title}{newline}Machine: {machine}{newline}Application Domain: {appDomain}{newline}Process Id: {processId}{newline}Process Name: {processName}{newline}Win32 Thread Id: {win32ThreadId}{newline}Thread Name: {threadName}{newline}Extended Properties: {dictionary({key} - {value}{newline})}"))
.SendTo.EventLog("Formatted EventLog TraceListener")
.FormatWithSharedFormatter("Text Formatter")
.ToLog("Application")
.LogToCategoryNamed("General").WithOptions.SetAsDefaultCategory()
.SendTo.Database("Formatted Database TraceListener")
.UseDatabase("MyDatabase")
.FormatWith(new FormatterBuilder().TextFormatterNamed("TextFormat"))
.WithWriteLogStoredProcedure("WriteLog")
.WithAddCategoryStoredProcedure ("AddCategory")
.LogToCategoryNamed("DBLogger").WithOptions.SetAsDefaultCategory();
builder.ConfigureData()
.ForDatabaseNamed("MyDatabase")
.ThatIs.ASqlDatabase()
.WithConnectionString("Data Source=.\SQLExpress;Initial Catalog=Logging;Integrated ecurity=True;")
.AsDefault();
The LogToCategoryNamed method has to come first. Something like this:
.LogToCategoryNamed("DBLogger")
.SendTo.Database("Formatted Database TraceListener")
.UseDatabase("MyDatabase")
.FormatWith(new FormatterBuilder().TextFormatterNamed("Text Formatter"));
Documentation on using the fluent API for logging can be found here.

Related Links

Parameter discovery is not supported for connections using GenericDatabase.
Where is the default installation folder of microsoft enterprise library?
Enterprise library with Oracle Managed Data Access
Failed to find or load the registered .Net Framework Data Provider on local machine
Data Access Application Block Configaration settings
How to deploy an application that uses enterprise library
Error in “Extensibility Hands-on Labs for Microsoft Enterprise Library 5.0”
DB logging using Fluent Interface

Categories

HOME
log4j
jdo
activiti
c#-4.0
iterator
read-eval-print-loop
rsync
filtering
react-redux
v8
dxl
yum
convolution
uber-api
qore
contact
gnupg
reveal.js
gz
clearcase-ucm
django-simple-history
clojurescript
jsdoc
excel-vba-mac
lucene.net
immutable.js
errorlevel
angular2-aot
opennlp
microsoft-sync-framework
django-storage
brunch
windows-error-reporting
applozic
vision
unboundid
galsim
data-manipulation
http-get
libraries
webix-treetable
jna
awt
galen
gulp-sourcemaps
estimote
s
qwt
worksheet
fancybox-2
font-size
flutterwave
wdf
bonobo
pcf
py2app
django-debug-toolbar
jwplayer7
pyke
reactive-banana
lib.web.mvc
marching-cubes
django-unittest
content-length
pundit
angular-leaflet-directive
interrupted-exception
device-orientation
npapi
geonetwork
typekit
dd
javafx-webengine
codeigniter-routing
issuu
marmalade
dir
web2py-modules
dbconnection
easy-install
qt-faststart
orchardcms-1.7
sabredav
isnullorempty
bluepill
pysimplesoap
twrequest
viewswitcher
nsmanagedobject
removeclass
semantic-diff
nsdatecomponents
coredump
rfc1123
calling-convention
jmock
mysql-error-1005
fluent-interface
sudzc
blitz++
avatar
uiq3

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App