问题
We're already using ELMAH for error logging on an ASP.NET MVC website that we have ... but our main website is still classic asp and I've begun creating an error handling/ logging structure for that website, but I thought it would be great if we could keep the error logging consistent across all our applications. I'd like to use the same database structure ... perhaps even store the errors from different source applications in the same table and then filter by source. I thought maybe that I could call out to the ELMAH dll from our classic asp vb server code to log the error information. I took a look at the ELMAH website ... and then I took a look at AIRBRAKE - http://airbrake.io/pages/home - but couldn't really see how it would be or could be done from a classic asp web page.
If anyone has any experience with this or has any suggestions that would be helpful I'd appreciate it ... thanks.
回答1:
Inspired by Bill Martin's answer, I've put together a proof-of-concept that demonstrates this working. There's a classic ASP handler that calls Server.GetLastError()
, encodes the result as JSON and POSTs it to a .NET HttpHandler, which then logs it to ELMAH alongside all the regular .NET errors.
The code and notes are at https://github.com/dylanbeattie/ElmahASP
回答2:
Depending on how long you plan to stay on classic asp, one option would be to create a temporary .Net site that has elmah enabled for trapping classic asp errors. Your classic ASP site would send this site the errors by means of a post or something, using security to prevent unwanted posts. You would need to parse the data sent and manually call elmah to log the error.
Then, when you upgrade, use the same settings and your logging will be seamless between the 2 versions.
来源:https://stackoverflow.com/questions/8883071/elmah-errors-and-classic-asp