satmisha
asked on
Best way to do logging in WCF application
Hi Experts, I have designed soap based wcf web services using VS 2013, Sql Server 2012. Now I want to do logging in that , Can you please suggest best way for logging.
This application being comsumed at different client level. Please let me know if you require any other information.
This application being comsumed at different client level. Please let me know if you require any other information.
I think you can enable Message Logging and Tracking for your services, by default it is not turned ON, we need to configure it to turn it ON. Also it has option to enable it on client as well as server side of WCF component.
you can refer below links which give step by step introduction to configure this messaging and tracing.
1> WCF Logging for SOAP services
2> WCF Messaging and Tracing
When a message is recorded, the trace type depends on whether it is being traced at the client or the server. For example, an "Add" message that is sent to a client is traced under the "TransportWrite" category at the client, whereas the same message is traced under the "TransportRead" category at the service.
3> You can also download the samples from below link and in that refer samples at <InstallDrive>:\WF_WCF_Sam ples\WCF\B asic\Manag ement\Trac ingAndLogg ing
Samples
you can refer below links which give step by step introduction to configure this messaging and tracing.
1> WCF Logging for SOAP services
2> WCF Messaging and Tracing
When a message is recorded, the trace type depends on whether it is being traced at the client or the server. For example, an "Add" message that is sent to a client is traced under the "TransportWrite" category at the client, whereas the same message is traced under the "TransportRead" category at the service.
3> You can also download the samples from below link and in that refer samples at <InstallDrive>:\WF_WCF_Sam
Samples
ASKER
Thanks Karrtik.
Is there a way to limit the logging just to ensure volume of log files not take too much server memory if I go with the the first link provided above ?
if so than how could I customize the logging as it appears to me the in the default logging it would log everything which might not good from memory management perspective.
Is there a way to limit the logging just to ensure volume of log files not take too much server memory if I go with the the first link provided above ?
if so than how could I customize the logging as it appears to me the in the default logging it would log everything which might not good from memory management perspective.
For tracing and messaging, you can set the level of logging/tracing to limit the log size, by setting the switchValue in the XML file something like below.
Recommended Settings
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
Or <source name="UserTraceSource" switchValue="Warning, ActivityTracing" >
Please find below the recommended settings for production environment.Recommended Settings
Also Microsoft recommends below to reduce performance cost.
Lessening Performance Cost
Setting ActivityTracing to off in the System.ServiceModel trace source generates a trace file that contains only user-defined activity traces, without any of the ServiceModel activity traces included. This results in a log file of much smaller size. However, the opportunity to correlate WCF processing traces is lost.
https://msdn.microsoft.com/en-us/library/aa354511%28v=vs.110%29.aspx
Lessening Performance Cost
Setting ActivityTracing to off in the System.ServiceModel trace source generates a trace file that contains only user-defined activity traces, without any of the ServiceModel activity traces included. This results in a log file of much smaller size. However, the opportunity to correlate WCF processing traces is lost.
https://msdn.microsoft.com/en-us/library/aa354511%28v=vs.110%29.aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Karrtik,
My apologies for delay in response.
One last thing in this, which approach is better suggested one i.e. in *.svc file or database approach where we can keep our logging information.
Nishant.
My apologies for delay in response.
One last thing in this, which approach is better suggested one i.e. in *.svc file or database approach where we can keep our logging information.
Nishant.
We have used file based approach thus far. Only reason I could think of storing log data in database is when I would want to perform some kind of analytics or heavy querying on this log data.
ASKER
Thanks Karrtik. Happy you to have on expert exchange. Thanks for your suggestion and again apologies for my delay response.
Thanks you so much.
Thanks you so much.
No problems, you are welcome nishant :)
ASKER