Logging with Elmah

482 views
Skip to first unread message

Ethan Blyth

unread,
Aug 9, 2012, 12:14:51 PM8/9/12
to servic...@googlegroups.com
Hi guys,

I am trying to get some simple exception logging up and running on my box but I'm struggling and hope you can point me in the right direction.

I basically want to be able to browse ELMAH errors like it says here http://johan.driessen.se/posts/simple-exception-logging-with-elmah

I've read the ServiceStack logging overview here http://www.servicestack.net/docs/logging/logging-overview but I can't work out what I need to put in the SetConfig() section of the app startup?


I have:

SetConfig(new EndpointHostConfig {
                DebugMode = true//Show StackTraces when developing
                LogFactory = new ElmahLogFactory()
			});

but ElmahLogFactory expects its an ILogFactory in the constructor but it itself is an ILogFactory. I'm not sure what to put in there apart from creating my own class that implements ILogFactory. If I do that I end up with a GetLogger method and then I have to create another class that implements ILog. I haven't filled in any details yet as I felt I was going down the wrong road.

Can someone help a brother out so I can view exceptions in my elmah.axd (I will modify this page address don't worry).


Thanks in advance,

Ethan



Arxisos

unread,
Aug 10, 2012, 5:53:59 AM8/10/12
to servic...@googlegroups.com
Hi Ethan,

"Only Error and Fatal are passed along to Elmah, while all other errors will be written to the wrapped logger."

If you want to tweak this behavior, you should be able to do that by changing the Elmah log factory source code:  https://github.com/ServiceStack/ServiceStack.Logging/tree/master/src/ServiceStack.Logging.Elmah 

Cheers,
Steffen

Jon Canning

unread,
Aug 10, 2012, 7:28:39 AM8/10/12
to servic...@googlegroups.com
Just installing Elmah from NuGet should set up exception logging. If you want to use Elmah for general purpose logging then try this approach:

Ephraim Mower

unread,
Aug 10, 2012, 9:51:35 AM8/10/12
to servic...@googlegroups.com
The Elmah log factory you're using is only a supplement to whatever other logger you are using, which is why it takes an ILog (your standard logger - log4net, etc.) in the constructor. Your standard logger takes care of typical logging, and Elmah only receives Error and Fatal. 
Reply all
Reply to author
Forward
0 new messages