How do I delete the log files that Elmah generates on the server?
Is there a setting within Elmah that I can use to delete log files? I would prefer to specify some criteria (e.g. log files that are older than 30 days).
Or should I write my own code for that ?
You can set the maximum number of log entries, but there isn't a native function for clearing out logs older than a given date. It's a good feature request, though!
If you are storing your error logs in memory the maximum number stored is 500 by default and this requires no additional configuration. Alternatively, you can define the number using the size
keyword:
<elmah>
<errorLog type="Elmah.MemoryErrorLog, Elmah" size="50" />
</elmah>
Setting a fixed size is obviously more important for in-memory or XML-based logging, where resources need to be closely managed. You can define a fixed size for any log type though.