Enabling logging/debugging in Azure worker role to azure storage

主宰稳场 提交于 2019-12-11 08:29:25

问题


I have a .net project that I am trying to deploy as a worker role in Azure. I am able to publish the file directly from Visual Studio but then when the worker role runs I am getting a uncaught exception. I am attempting to enable logging to azure storage from the worker role so I can get more information on the exception but I am running into issues getting MIT configured. Can anyone provide assistance on the best way to enable this logging?


回答1:


I’m not a massive fan of the recommended Azure Worker Role logging process, namely using the Trace.WriteLine() method as I don’t feel as though it provides sufficient flexibility for my logging needs and I think it looks crap when my code is liberally scattered with Trace.WriteLine() statements, code is art and all that. I also don't like that Trace statements aren't always logged and can be 'lost' if the Worker Role hiccups or generally goes astray.

I therefore came up with an approach that writes log files to local storage via NLog, which are then flushed to Azure Storage on a schedule. Works like a charm.

I've got it documented over in the blog post at: https://modhul.wordpress.com/2014/10/28/capturing-custom-logs-from-azure-worker-roles-using-azure-diagnostics/

If I want to watch my log files in real-time (rather than waiting for them to be flushed to Azure Storage), I RDP into the Worker Role instance and fire-up a copy of BareTail (http://www.baremetalsoft.com/baretail/) which is a great way of watching log files in real-time, it also lets you add colour-coding for errors, info, warnings etc.



来源:https://stackoverflow.com/questions/28423610/enabling-logging-debugging-in-azure-worker-role-to-azure-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!