wcf获取MySQL中午乱码,如何启用WCF日志记录,以便它写入数据库?
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.
解決方案
You need to have two things:
a proper config to enable .NET tracing
a trace listener to capture the trace messages and store them in a database
For #1:
You need to turn on tracing in WCF first - you need an entry in that enables tracing:
logEntireMessage="true"
logMalformedMessages="false"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="false"
maxMessagesToLog="300000"
maxSizeOfMessageToLog="200000"/>
Next, you need to configure .NET tracing as such:
switchValue="Information, ActivityTracing"
propagateActivity="true">
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).
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的wcf获取MySQL中午乱码,如何启用WCF日志记录,以便它写入数据库?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 商用计算机低温工作,突破量子计算机瓶颈!
- 下一篇: 电脑手写板_点到之处妙笔生花,实用平板电