I’d like to be able to log message information in a database, and I’m trying to decide how best to do that. Is it possible to configure the WCF logging mechanisms to write to a database instead of a file? Thanks.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to have two things:
For #1:
You need to turn on tracing in WCF first – you need an entry in
<system.serviceModel>that enables tracing:Next, you need to configure .NET tracing as such:
Here, instead of the WebTraceListener, or other pre-defined listeners, you can also plug in your own database-oriented trace listener.
For #2:
You can – of course – write your own
SqlTraceListener– or you can use one of the many ready-made solutions out there, for instance this one here (download the code from Codeplex).