Writing a logger to monitor exceptions via e-mail
In this recipe, we will look at creating a simple way to make sure you're aware of any exceptions your web services are throwing. We will write our own implementation of ILog
and ILogFactory
that ServiceStack provides as a generic way of logging information.
We have had mixed experiences with e-mail loggers in large-scale production environments—it's not a great practice unless a significant amount of sophisticated logic goes into figuring out which errors constitute something interesting, and which don't. Having said that, it's still a useful technique for smaller applications and makes a great example for how to structure your own logger.
Getting ready
First, we will need some services to work with. In this example, we will use GreetingService
, so we can focus on how we can incorporate our e-mail logger to the application. If you are starting from a new project, please read Creating a ServiceStack solution with Visual Studio and NuGet in Appendix...