eric_eri
eric_eri

Reputation: 709

A way to have different LogPaths for elmah, based on error types

I am looking for a way to have different log path for different error types in my web api project. What I want is to put System.Web.HttpException errors in different folder and my other errors in a another folder. The reason for that is, I receive so many System.Web.HttpException errors which most of them are irrelevant but I still need to log them but in a different folder. My elmah setup is a standard one.

this is my web config tag:

<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/ErrorLog" />
<security allowRemoteAccess="false" />
</elmah>

any help is much appreciated.

Upvotes: 0

Views: 158

Answers (1)

ThomasArdal
ThomasArdal

Reputation: 5229

The short answer: You can't. XmlFileErrorLog only supports a single directory as logPath.

If you want to implement this, you would need to fork the ELMAH source code and override the Log-method of XmlFileErrorLog.

Another approach could be to use ELMAH error filtering to ignore all System.Web.HttpException errors and then use another logging framework to log those errors. If you set up log4net, NLog, Serilog or similar, you could make that integration log all errors (including the HTTP exceptions).

Upvotes: 1

Related Questions