Customize elmah.axd output fields

…衆ロ難τιáo~ 提交于 2019-12-19 02:15:10

问题


ELMAH shows host, code, type, error, user, date and time by default on its error log web page. Is there any way to configure it and show other fields like IP or REFERER?


(source: googlecode.com)


回答1:


ELMAH is open-source. You can download the source and make any modifications you like (within the terms of the license, of course.)

You should be able to trap any data made available by the HttpConext.Request object. You'd have to modify the code that grabs and stores the data, and the database to make columns for that new data.




回答2:


You could write your own error page. Bind a datagrid to ErrorLog.GetErrors() and use whatever columns you want:

List<ErrorLogEntry> entries = new List<ErrorLogEntry>();
ErrorLog.GetDefault(HttpContext.Current).GetErrors(0, 50, entries);
string ip = entries[0].Error.ServerVariables["REMOTE_ADDR"];
string referrer = entries[0].Error.ServerVariables["HTTP_REFERER"];


来源:https://stackoverflow.com/questions/2547211/customize-elmah-axd-output-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!