|
ExceptionHandling
Exception logging and worker restart
The problemAt this date, there is no logging system (*) provided with Windows Azure. In addition, each uncaught exception triggers a worker restart at the VM level which takes about 2min. (*) It's not entirely true, but the default logging system shipped is so crude that it is less than useful for practical situations. The solution: Built-in loggingLokad.Cloud comes with a built-in logger directly inspired by elmah. The logger is directly available as a CloudService property: public abstract class CloudService
{
public ILog Log
{
get { /* snipped */ }
}
}The logger can be used to log info or errors. The logs can then be browsed from the Error Logs panel in the web administration console. Technical note: we are considering adapting elmah in the future. Exception logging and worker restartAny uncaught exception thrown by the client app built on top of Lokad.Cloud gets automatically logged. After logging the exception, the worker is automatically restarted. It must be noted that Lokad.Cloud runs the client app in a separate AppDomain. Thus, in case of uncaught exception, the client AppDomain is simply unloaded and reloaded. Bottom-line result: restarting the worker after a failure takes about 2s - compared 2min for a restart at the VM level. It is possible for a CloudService to force a worker restart by throwing a TriggerRestartException (part of Lokad.Cloud). |