Super Simple Logging on AppHarbor
AppHarbor uses ASP.NET Health Monitoring to log and display exceptions thrown by applications running on the platform. Enterprising AppHarbor users have used this feature for debugging purposes by throwing exceptions from their their code. Throwing an exception is inconvenient however, since doing so interrupts normal program flow.
Below is a simple example demonstrating how to subvert ASP.NET Health Monitoring and make AppHarbor log messages. Logged messages are available for inspection in the application Error Display and logging messages like this does not involve throwing an exception.
Note that this is not anything like a replacement for application event tracking solutions such as Airbrake or Logentries, but it's pretty neat if you just need a simple way to output some debugging information while your application is running on AppHarbor.
using System;
using System.Web.Management;
using System.Web.Mvc;
namespace ErrorLoggingSample.Controllers
{
public class ErrorController : Controller
{
public ActionResult Index()
{
new LogEvent("message to myself").Raise();
return View();
}
}
public class LogEvent : WebRequestErrorEvent
{
public LogEvent(string message)
: base(null, null, 100001, new Exception(message))
{
}
}
}