Error Signal .raise
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Elmah add message to error logged through call to Raise(e) up vote 11 down vote favorite 4 I'm a bit confused at how to add a message to an error logged programatically with ELMAH. eg: public ActionResult DoSomething(int id) { try { ... } catch (Exception e) { // I want to include the 'id' param value here, and maybe some // other stuff, but how? ErrorSignal.FromCurrentContext().Raise(e); } } It seems all Elmah can do is log the raw exception, how can I also log my own debug info? c# .net elmah error-logging share|improve this question asked Sep 28 '10 at 12:15 fearofawhackplanet 18.2k36113220 1 curious why Elmah doesn't have an overload for Raise for additional messages. contextual information is vital when trying to fix certain errors –Simon_Weaver Feb 8 '13 at 11:14 add a comment| 2 Answers 2 active oldest votes up vote 17 down vote accepted You can throw a new Exception setting the original as the inner exception and ELMAH will log the messages for both: catch(Exception e) { Exception ex = new Exception("ID = 1", e); ErrorSignal.FromCurrentContext().Raise(ex); } will show System.Exception: ID = 1 ---> System.NullReferenceException: Object reference not set to an instance of an object. share|improve this answer edited Sep 28 '10 at 13:30 answered Sep 28 '10 at 13:24 Jeff Ogata 35.7k1286110 nice idea, thanks –fearofawhackplanet Sep 28 '10 at 14:20 works great! thanks! –Justin Williams Jan 7 '11 at 22:38 you should use Exception.Data, but by default elmah does not have this functionality. I added to a custom version I use. I really should post the code up somewhere. I know this is old but I think this is not 100% correct. Yes you can use this for small details, but if you want a list of data that's what the Exception.Data was made for. For example when an SQLException is thrown you get a lot of details. I also added this. It's not really hard to do yourself. Also when working with linq2sql you can
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join http://stackoverflow.com/questions/3812538/elmah-add-message-to-error-logged-through-call-to-raisee them; it only takes a minute: Sign up Error signalling in ELMAH not working with ASP.NET MVC up vote 1 down vote favorite My understanding is that raising an errorsignal should log my error or hit the custom HandleErrorWithELMAHAttribute class(taken from this example) ,But it does neither. I am using the HandleErrorWithElmah decorator for the controller in question.The error http://stackoverflow.com/questions/3810526/error-signalling-in-elmah-not-working-with-asp-net-mvc logging works when it comes to unhandled exceptions in the controller(I am explicitly calling Logexception and not using conditions mentioned in the second code block of example). But the error signalling feature which is to be used for handled errors is keeping me baffled. How does error signalling work...Is it supposed to do something other than Logging...If so how can i use it log my handled exceptions? This is the code i am using to signal handled errors ErrorSignal.FromCurrentContext().Raise(new Exception("Some Handled Error")); And below are snippets of my settings in web config
tips Subscriptions Issue 148: Return ErrorId from Raise 3 people starred this issue and may be notified of changes. Back to list Status: WontFix Owner: ---- Closed: https://code.google.com/p/elmah/issues/detail?id=148 Jan 2010 Type-Enhancement Priority-Medium Sign in to add a comment Reported by SQFoun...@gmail.com, Jan 7, 2010 What new or enhanced feature are you proposing? For the ErrorSignal.FromCurrentContext().Raise() method to return the error id What goal would this enhancement help you achieve? I would like to give users the id for the error that was generated for correlation back to teh errors in the log. This error signal would help us drive better communications between our end-users and server admins/developers. It would also be useful when logging to TFS so we can correlate between the error log and the TFS work item. Jan 7, 2010 #1 SQFoun...@gmail.com So I guess you could return the error id in the events args of the Raised Event Args. For now there only seems to be the context error signal .raise and exception objects in there currently. Jan 7, 2010 Project Member #2 azizatif Raising an error signal does not mean an error will be logged so an ID cannot be guaranteed or supplied through this mechanism. Raising an error signal simply informs listening parties of an error. If you want to obtain the ID of a logged error, you need to subscribe to the Logged event of the ErrorLogModule. See the following post to get started: http://groups.google.com/group/elmah/msg/fcedb430b121e2dc The arguments of the logged event are represented by ErrorLoggedEventArgs: https://code.google.com/p/elmah/source/browse/tags/REL- 1.1/src/Elmah/ErrorLogModule.cs#179 It contains a single Entry property whose Id property will give you what you're looking for. See also: https://code.google.com/p/elmah/source/browse/tags/REL- 1.1/src/Elmah/ErrorLogEntry.cs#85 The ErrorLogModule module, when registered, subscribes to error signaling so when someone calls Raise, it will log the error. I'm setting the status of this issue as WontFix as this functionality is already available. If you need more help, please post to the discussion group instead: http://groups.google.com/group/elmah Status: WontFix May 2, 2012 #3 robr...@robrich.org The following patch adds this feature: diff -r 2482ebd0a4ae src/Elmah/ErrorLogModule.cs --- a/src/Elmah/ErrorLogModule.cs Tue May 01 19:31:20 2012 +0200 +++ b/src/Elmah/ErrorLogModule.cs Wed May 02 16:07:07 2012 -0700 @@ -84,15 +84,21 @@ protected virtual void OnErrorSignale