letsgetsilly
letsgetsilly

Reputation: 1196

How do I manage WCF log file sizes programatically?

We're having a bit of trouble managing the file size of the WCF logs at my organization. The logs are getting large, really large. Multiple gigabytes of data.

I am a bit of a WCF rookie, but I realize that there are options to turn down the level of information being logged. However, what I'd prefer to do is setup some sort of automatic archiving process for the logs, so that on a certain frequency (maybe every night) the logs are automatically archived into a separate folder for up to 5 days. This way we can have fresh and manageable log sizes in the morning when we discover an issue with one of our services.

I don't really know what the best approach to this would be. Are there .NET classes that give me access to the SVC log files? Or, would I need to write a service that specifically turns off the service, renames and moves the logs on the file system, then turns the service back on?

Any help is appreciated!

Upvotes: 5

Views: 7704

Answers (1)

kroonwijk
kroonwijk

Reputation: 8410

There is a nice CodeProject for rolling your WCF service logs:

Ever had the problem of growing svclog files after configuring tracing in a productive WCF environment? Did not want to restart the application just for deleting or moving the trace files?

Then, you will like the RollingXmlWriterTraceListener, which is a specialized XmlWriterTraceListener, and is completely compatible with the WCF tracing facility.

Does the trick nicely ...

Upvotes: 10

Related Questions