Is it possible to log exception like ThrowMaxReceivedMessageSizeExceeded from my WCF service. I know that the message size can be increased in the config but I would also like it logging on my side. I have Log4Net running to catch all unhandled exceptions but it seems this is so not getting logged, so is probably handled.
Asked
Active
Viewed 6,038 times
2 Answers
5
You need to enable Tracing. That can be sent to Nlog. My XYZ.exe.config has a section which looks like that:
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Error" propagateActivity="true" >
<listeners>
<add name="nlog"/>
</listeners>
</source>
<!--source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="nlog" />
</listeners>
</source-->
</sources>
<sharedListeners>
<add name="nlog" type="NLog.NLogTraceListener, NLog" />
</sharedListeners>
</system.diagnostics>
NOTE: I have the NLog config in the XYZ.exe.config as well!
EDIT
I just realized that you were talking about log4net. Not NLog.
If you follow the last link provided by StephaneT and implement the Log4netTraceListener
you should be able to use the XYZ.exe.config solution as well.