albertocolom / elmah

Automatically exported from code.google.com/p/elmah
Apache License 2.0
0 stars 0 forks source link

XmlFileErrorLog exception when non XML files are in the same folder #45

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Retrieving errors with the XmlFileErrorLog throws an exception if the
folder the logPath configuration attribute points to contains other files,
non-XML or XML but with a different scheme - say, not containing error logs.

Original issue reported on code.google.com by simone.b...@gmail.com on 8 Nov 2007 at 3:12

GoogleCodeExporter commented 8 years ago
How do you reckon this happens? Looking at the code 
(http://elmah.googlecode.com/svn/trunk/src/Elmah/XmlFileErrorLog.cs, r211
), there is a filtering on the naming pattern at the following lines:

Line #142:
string path = Path.Combine(LogPath, string.Format(@"error-{0}-{1}.xml", 
timeStamp, 
errorId));

Line #247:
string[] files = Directory.GetFiles(LogPath, string.Format("error-*-{0}.xml", 
id));

Original comment by azizatif on 8 Nov 2007 at 3:44

GoogleCodeExporter commented 8 years ago
I didn't look into the code, I just noticed that the error case happened when I 
had a
file named Elmah.db in the same folder where the errors logged by the XML 
provider
were. Removing the file from there solved the problem.

Original comment by simone.b...@gmail.com on 8 Nov 2007 at 3:54

GoogleCodeExporter commented 8 years ago
Yep, you're right. Seems like line #179 is the culprit (that I missed the first 
time):

  FileSystemInfo[] infos = dir.GetFiles();

One could argued that the log path should be void of types of files but I guess 
it's 
a simple case to rule out so why not.

Original comment by azizatif on 8 Nov 2007 at 4:02

GoogleCodeExporter commented 8 years ago
Yes, I was getting back to you on this. Not too hard to solve.

Original comment by simone.b...@gmail.com on 8 Nov 2007 at 4:08

GoogleCodeExporter commented 8 years ago
Fixed in r240.

Original comment by azizatif on 8 Nov 2007 at 4:38