在 Azure 辅助角色中启用日志记录/调试到 azure 存储 [英] Enabling logging/debugging in Azure worker role to azure storage

查看:38
本文介绍了在 Azure 辅助角色中启用日志记录/调试到 azure 存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .net 项目,我尝试将其部署为 Azure 中的辅助角色.我可以直接从 Visual Studio 发布文件,但是当辅助角色运行时,我遇到了一个未捕获的异常.我正在尝试从辅助角色启用日志记录到 azure 存储,以便我可以获得有关异常的更多信息,但我在配置 MIT 时遇到了问题.任何人都可以提供有关启用此日志记录的最佳方式的帮助吗?

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?

推荐答案

我不太喜欢推荐的 Azure Worker Role 日志记录过程,即使用 Trace.WriteLine() 方法,因为我不觉得它为我的日志记录需求提供了足够的灵活性,我认为当我的代码大量散布着 Trace.WriteLine() 语句时,它看起来很糟糕,代码就是艺术等等.我也不喜欢 Trace 语句并不总是被记录下来,如果 Worker Role 出现问题或通常误入歧途,它可能会丢失".

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.

因此,我想出了一种方法,通过 NLog 将日志文件写入本地存储,然后按计划将其刷新到 Azure 存储.奇迹般有效.

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.

我在博客文章中记录了它:https://modhul.wordpress.com/2014/10/28/capturing-custom-logs-from-azure-worker-roles-using-azure-diagnostics/

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/

如果我想实时查看我的日志文件(而不是等待它们被刷新到 Azure 存储),我将 RDP 到 Worker Role 实例并启动 BareTail 的副本(http://www.baremetalsoft.com/baretail/) 这是实时查看日志文件的好方法,它还允许您为错误、信息、警告等添加颜色编码.

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.

这篇关于在 Azure 辅助角色中启用日志记录/调试到 azure 存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆