elmah/Elmah

Use application name in XmlFileErrorLog when logging an error

Opened this issue · 10 comments

Use application name in XmlFileErrorLog when logging an error

@nbulusanjr @atifaziz I did fix a similar issue in the memory error log. Maybe this code can just be ported to the XML file logger as well. Looks like it is missing the application name completely.

The application name setting was primarily designed to be used for isolation purposes where you'd want to share a single store like a database as the error log store across several applications. It doesn't make much sense in the case of XmlFileErrorLog where you can get isolation simply by using different path per application to store the XML files. This is not so much an issue at the time of writing as it is when listing the error log. ELMAH will have to crack open each XML file in a large directory of files to be able to filter by application. A database can do this efficiently via an index. The application name is not an integral part of the logged error but I think most people want to use it for informational purposes.

Since this is by-design, I've changed the title and label to reflect that this is an enhancement.

But if you want to share the directory where XmlFileErrorLog puts its files between multiple applications (like a SAN), application name may still make sense, right?

@ThomasArdal It could but it cannot be efficiently implemented as I pointed out:

ELMAH will have to crack open each XML file in a large directory of files to be able to filter by application. A database can do this efficiently via an index.

The only way to make this work would be to use the application name as the last component of the file path and then each application's errors would sit isolated in a separate directory. Historically, this made sense if you configured the error log machine-wide via machine.config (e.g. in a shared application hosting environment) and then the only thing an app had left to do was configure it's application name. Isolation would then happen automagically if the error log implementation supported it. I would discourage anyone using XmlFileErrorLog in the same way even if it could be technically possible. It's meant for a lightweight solution where a database is not available.

A guy from OrbitOne did an application thats logs to a central database and filter it using by application name. The design log an error to a xml file and an agent will check if there is a new xml file in your log directory and throws into a webservice.

@nbulusanjr I'm guessing you're referring to ASP.NET Exception Reporter (based on ELMAH)?

an agent will check if there is a new xml file in your log directory and throws into a webservice.

Can the agent not be configured with the application for which it is collecting?

Hi, I want to fix this issue in Elmah. Can I get access to make PR in master and publish new nuget for the same?

@vyasabhishek You don't need any access rights to make a PR. You prepare the work in your fork and create a PR from there to here. Also, the fix should go primarily into the 1x branch as that relates to 1.x releases. As for NuGet, you'd need the package owners (@JamesDriscoll & I) to push out a release. @JamesDriscoll used to take care of most of the packaging but I think he's quite busy now.

Thanks @atifaziz . I have created PR to main branch. I would appreciate, If you can review/merge that PR and publish a new version of Elmah.