Web.config 配置文件修改:
<system.serviceModel> <diagnostics> <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="2147483647" maxSizeOfMessageToLog="2147483647"/> </diagnostics> </system.serviceModel> <system.diagnostics> <trace autoflush="true" /> <sources> <source name="System.ServiceModel.MessageLogging"> <listeners> <add name="ServiceModelMessageLoggingListener"> <filter type=""/> </add> </listeners> </source> </sources> <sharedListeners> <add initializeData="Messages.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp"> <filter type=""/> </add> </sharedListeners> </system.diagnostics>
若使用上面的配置,则日志文件保存在项目根目录下,日志文件名为:Messages.svclog
若查看该日志文件,可使用SvcTraceViewer.exe
SvcTraceViewer.exe 工具存放路径:C:Program Files (x86)Microsoft SDKsWindowsv10.0AinNETFX 4.6.1 Tools(根据个人电脑配置不同,可能存放的位置存在一定的差异)