简体   繁体   English

如何将自定义事件字符串写入Aws cloudwatch日志

[英]How do I write a custom event string to Aws cloudwatch logs

I have spent hours digging through Aws documentation, and I cannot find ac# 'hello world' type sample showing how to programmatically write something simple (like a string or something similar) to Aws cloud watch logs. 我花了几个小时挖掘Aws文档,我找不到ac#'hello world'类型示例,展示了如何以编程方式将简单的东西(如字符串或类似的东西)写入Aws云监视日志。 Perhaps I am not looking in the right place, but Amazon's sdk documentation and code samples seems to be lacking. 也许我没有找对地方,但亚马逊的sdk文档和代码示例似乎缺乏。 Anyone have a link to the (probably) 10 lines of code I need? 任何人都有一个链接到(可能)我需要的10行代码?

After some time I have come to the conclusion that there is no simple way to write individual events to AWS in an atomic fashion. 一段时间后,我得出的结论是,没有简单的方法以原子方式将单个事件写入AWS。 You can write a single event to a logfile, and send that to AWS. 您可以将单个事件写入日志文件,然后将其发送给AWS。 However, AWS really isn't the tool for streaming logs to a repository in real time. 但是,AWS实际上不是实时将日志流式传输到存储库的工具。 There are much better providers available for performing actions like that. 有更好的提供程序可用于执行此类操作。

Yo can simply write it to the file, and then read it from file with the help of AWS logs agent. Yo可以简单地将其写入文件,然后在AWS logs代理的帮助下从文件中读取它。 Here is the link that explains how to configure your EC2 instance to do that. 以下是解释如何配置EC2实例的链接

Cloudwatch supports integration with a few common logging frameworks - https://aws.amazon.com/blogs/developer/amazon-cloudwatch-logs-and-net-logging-frameworks/ Cloudwatch支持与一些常见的日志框架集成 - https://aws.amazon.com/blogs/developer/amazon-cloudwatch-logs-and-net-logging-frameworks/

You can find configuration samples in their github repo - https://github.com/aws/aws-logging-dotnet 您可以在他们的github repo中找到配置示例 - https://github.com/aws/aws-logging-dotnet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM