I just installed Elmah (https://code.google.com/p/elmah/) for my ASP.NET application. Is it possible to log a message without creating an Exception first?
catch(Exception e) { Exception ex = new Exception("ID = 1", e); ErrorSignal.FromCurrentContext().Raise(ex); }
So is it possible to do:
ErrorSignal.FromCurrentContext().log("Hello I am testing Elmah");
Build the application, run it in the browser, and navigate to http://www.yoursite.com/elmah.axd. You are prompted to log in before you see the content. After a successful authentication, you see a web page to remotely view the entire log of recorded exceptions.
ELMAH (Error Logging Modules and Handlers) is an application-wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a machine, without any need for re-compilation or re-deployment.
elmah.io for ASP.NET Core supports a range of actions for hooking into the process of logging messages. Hooks are registered as actions when installing the elmah.io middleware: services.
Yes, you can use ErrorSignal without throwing an exception.
ErrorSignal.FromCurrentContext().Raise(new NotSupportedException());
For the custom message, you can create a custom exception.
var customEx = new Exception("Hello I am testing Elmah", new NotSupportedException()); ErrorSignal.FromCurrentContext().Raise(customEx);
Try this
Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Your message"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With