在 Azure 辅助角色中启用日志记录/调试到 azure 存储

编程入门 行业动态 更新时间:2024-10-28 07:33:24
本文介绍了在 Azure 辅助角色中启用日志记录/调试到 azure 存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

I have a 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/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/2014/10/28/capturing-custom-logs-from-azure-worker-roles-using-azure-diagnostics/

如果我想实时查看我的日志文件(而不是等待它们被刷新到 Azure 存储),我将 RDP 到 Worker Role 实例并启动 BareTail 的副本(http://www.baremetalsoft/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/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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-27 13:17:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1154963.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:角色   日志   Azure   azure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!