I have an existing .net service, and I want to configure it to write messages to a log file. I added in the following in the service configuration:
<system.diagnostics>
<sources>
<source name="My.Service" switchValue="All">
<listeners>
<add name="text" type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\log.txt" traceOutputOptions="Timestamp"/>
</listeners>
</source>
</sources>
</system.diagnostics>
The problem is that the log file becomes quickly very large, so I was wondering if it's possible to configure some sort of log rotation.
Since the process locks the file for writing, it's not possible to rotate it manually, say with a script periodically renaming the file, at least without stopping and restarting the service.
Thanks for any suggestion.