c# - WCF Service enable tracing -
after 2 days of try , error , blind debugging, web service still produces error in cases , now, don't know why. therefor, enable tracing service in order have @ least little feedback.
however, tried few addition web.config, none ever produced trace file, if service responded error.
so long, web.config:
<?xml version="1.0" encoding="utf-8"?> <configuration> <configsections> <section name="entityframework" type="system.data.entity.internal.configfile.entityframeworksection, entityframework, version=6.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089" requirepermission="false" /> </configsections> <connectionstrings> <...removed here... /> </connectionstrings> <appsettings> <add key="aspnet:usetaskfriendlysynchronizationcontext" value="true" /> </appsettings> <system.web> <customerrors mode="off"></customerrors> <compilation targetframework="4.5.1" /> <httpruntime targetframework="4.5.1" /> </system.web> <system.servicemodel> <services> <service name="timerechomepage.service.timeservice" behaviorconfiguration="timeservicebehavior"> <endpoint name="webhttpbinding" address="" binding="webhttpbinding" bindingconfiguration="webhttptransportsecurity" contract="timerechomepage.service.itimeservice" behaviorconfiguration="webhttp" /> <endpoint name="mexhttpbinding" address="mex" binding="mexhttpsbinding" contract="imetadataexchange" /> </service> </services> <bindings> <webhttpbinding> <binding name="webhttptransportsecurity"> <security mode="transport" /> </binding> </webhttpbinding> </bindings> <behaviors> <servicebehaviors> <behavior name="timeservicebehavior"> <servicemetadata httpsgetenabled="true" /> <servicedebug includeexceptiondetailinfaults="false" /> </behavior> <behavior> <servicemetadata httpgetenabled="false" httpsgetenabled="true" /> <servicedebug includeexceptiondetailinfaults="true" /> </behavior> </servicebehaviors> <endpointbehaviors> <behavior name="webhttp"> <webhttp defaultoutgoingresponseformat="json" automaticformatselectionenabled="true" defaultbodystyle="wrappedrequest" /> </behavior> </endpointbehaviors> </behaviors> <protocolmapping> <add binding="basichttpsbinding" scheme="https" /> </protocolmapping> <servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true" /> </system.servicemodel> <system.webserver> <modules runallmanagedmodulesforallrequests="true" /> <directorybrowse enabled="false" /> </system.webserver> <entityframework> <defaultconnectionfactory type="system.data.entity.infrastructure.localdbconnectionfactory, entityframework"> <parameters> <parameter value="v13.0" /> </parameters> </defaultconnectionfactory> <providers> <provider invariantname="system.data.sqlclient" type="system.data.entity.sqlserver.sqlproviderservices, entityframework.sqlserver" /> </providers> </entityframework> <runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentassembly> <assemblyidentity name="newtonsoft.json" publickeytoken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingredirect oldversion="0.0.0.0-8.0.0.0" newversion="8.0.0.0" /> </dependentassembly> <dependentassembly> <assemblyidentity name="system.web.mvc" publickeytoken="31bf3856ad364e35" culture="neutral" /> <bindingredirect oldversion="0.0.0.0-5.1.0.0" newversion="5.1.0.0" /> </dependentassembly> <dependentassembly> <assemblyidentity name="webgrease" publickeytoken="31bf3856ad364e35" culture="neutral" /> <bindingredirect oldversion="0.0.0.0-1.5.2.14234" newversion="1.5.2.14234" /> </dependentassembly> <dependentassembly> <assemblyidentity name="antlr3.runtime" publickeytoken="eb42632606e9261f" culture="neutral" /> <bindingredirect oldversion="0.0.0.0-3.5.0.2" newversion="3.5.0.2" /> </dependentassembly> </assemblybinding> </runtime> </configuration>
i looked configuration of tracing , tested entries web.config proposed e.g.here, here , read documentation.
as written in documentation, windows 8 on, need privileged rights in order trace, changed application pool identity, without success though (the service runs on win 2012 r2 server).
what missing in order enable , use tracing? thank in advance efforts!
you need 2 sections in web.config, 1 tracelisteners configured , diagnostics section in system.servicemodel.
system.diagnostics
add following section:
<system.diagnostics> <sources> <source name="system.servicemodel.messagelogging"> <listeners> <add name="messages" type="system.diagnostics.xmlwritertracelistener" initializedata="c:\temp\messages.svclog" /> </listeners> </source> <source name="system.servicemodel" switchvalue="information,activitytracing" propagateactivity="true"> <listeners> <add name="tracing" type="system.diagnostics.xmlwritertracelistener" initializedata="c:\temp\tracing.svclog" /> </listeners> </source> </sources> </system.diagnostics>
notice value of initializedata
, make sure add path there application identity can write. system wide tempfolder should option.
system.servicemodel diagniostics
adapt system.servicemodel
nd add diagnostics settings
<system.servicemodel> <diagnostics> <messagelogging logentiremessage="true" logmalformedmessages="true" logmessagesatservicelevel="true" logmessagesattransportlevel="true" maxmessagestolog="3000" maxsizeofmessagetolog="2000"/> </diagnostics> <!-- other stuff here --> </system.servicemodel>
test settings
with above config logifiles should created , tracing.scvlog
should show entries when service started or when request wsdl service. holds exceptions , stacktraces occur.