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.
相关问题
- Faster loop: foreach vs some (performance of jsper
- NOT DISTINCT query in mySQL
- Why wrapping a function into a lambda potentially
- Flush single app django 1.9
- I want to trace logs using a Macro multi parameter
相关文章
- WCF发布Windows服务 POST方式报错 GET方式没有问题 应该怎么解决?
- how do I log requests and responses for debugging
- XCopy or MOVE do not work when a WCF Service runs
- DOM penalty of using html attributes
- Connection pooling vs persist connection mysqli
- Which is faster, pointer access or reference acces
- Django is sooo slow? errno 32 broken pipe? dcramer
- Android Studio doesn't display logs by package
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).If you don't need the whole SOAP-message, I would suggest to use log4net with custom IParameterInspector or IDispatchMessageInspector implementation, cause in this case you can write to log only what you need. Otherwise, take marc_s's solution.
You can use Log4Net