I’m using .NET’s built-in Tracing mechanism to trace program execution. The problem is the trace file can grow to several MB very quickly. Is there an efficient way of truncating the file when it grows past a certain point? I thought of putting in a check whenever something gets written (I have a custom class that inherits from TraceListener) but that might degrade performance too much. Maybe a Timer would be a better solution?
Anyone have any ideas?
Implement a custom trace listener:
http://www.codeproject.com/KB/dotnet/customnettracelisteners.aspx?display=Print
With this example, you are able to create log chunck like this:
Of course, you can throw backup files away.
(Just a hint: try log4net (here) and Enterprise Library Logging Block (here)!)