Greetings,
I had the same desire and I put some code like this in
application_start
Sub DeleteElmahLogs()
Try
Dim fi As System.IO.FileInfo
Dim files() As String =
IO.Directory.GetFiles(HttpContext.Current.Server.MapPath("~/
App_Data/"), "*.xml")
For Each myfile In files
fi = New System.IO.FileInfo(myfile)
' In my environment the 30 comes from my.settings
If fi.CreationTime < Today.AddDays(0 - 30) Then
fi.Delete()
End If
Next
Catch ex As Exception
ErrorSignal.FromCurrentContext().Raise(ex)
End Try
End Sub
Works OK, but would I would really want, and I would be happy to * try
to develop, is a purge log feature that could be configured like
this:
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/app_data"
purgeLogsBy="DayCreated" purgeLogsThreshold="30"/>
* I am kind of a new developer.... spent years as a tester.
> On May 17, 4:46 am, Grzegorz Wołoszyn <
g.wolos...@gmail.com> wrote:
> Ok. Thank you. I think this could be a very nice feature.
>
> On 16 Maj, 21:15, Atif Aziz <
aziza...@gmail.com> wrote:
>
>
>
> > No,. Your best option is to setup a scheduled task in Windows to archive
> > and/or purge the directory on a regular basis.
>
> > Alternatively, you can inherit from the XmlFileErrorLog and override the Log
> > method in your implementation to, for example, enjoy full control over your
> > own purge policy.
>
> > - Atif
>
> > 2011/5/16 Grzegorz Wo³oszyn <
g.wolos...@gmail.com>
>
> > > Hello,
>
> > > is there any possibility to set limit number of XML error files stored
> > > in App_Data directory in web.config file?
>
> > > Regards
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "ELMAH" group.
> > > To post to this group, send email to
el...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > >
elmah+un...@googlegroups.com.
> > > For more options, visit this group at
> > >
http://groups.google.com/group/elmah?hl=en.- Hide quoted text -
>
> - Show quoted text -