4

I have spent hours digging through Aws documentation, and I cannot find a c# 'hello world' type sample showing how to programmatically write something simple (like a string or something similar) to Aws cloud watch logs. Perhaps I am not looking in the right place, but Amazon's sdk documentation and code samples seems to be lacking. Anyone have a link to the (probably) 10 lines of code I need?

Roger Hill
  • 3,677
  • 1
  • 34
  • 38
  • Did you check this http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html – Piyush Patil Jul 12 '16 at 16:48
  • That is an API reference, it might work if I wanted to re-invent the wheel and write something from scratch. They have a whole published sdk for this, somewhere there must be a SDK sample somewhere. – Roger Hill Jul 12 '16 at 16:52
  • Please check this [link](http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/send_logs_to_cwl.html), it might be helpful. – T. D. Ben Jul 12 '16 at 17:11
  • I read that article already. It has plenty of info about shipping existing logs (iis, text, etc) to the service, but not much about just programmatically pushing a string or int to the service. – Roger Hill Jul 12 '16 at 17:23
  • could you please elaborate what exactly you intend to do? – akhila Sep 21 '16 at 10:50
  • Write a single event or exception to the log. – Roger Hill Sep 23 '16 at 17:04

3 Answers3

2

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. You can write a single event to a logfile, and send that to AWS. However, AWS really isn't the tool for streaming logs to a repository in real time. There are much better providers available for performing actions like that.

Roger Hill
  • 3,677
  • 1
  • 34
  • 38
2

Cloudwatch supports integration with a few common logging frameworks - 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

Todd Hirsh
  • 51
  • 1
  • 4
  • Interesting new development. A bit late for my project, but certainly an option for people working on new code. Looks like they are adding support for individual events and real time monitoring. – Roger Hill Jun 11 '18 at 21:31
  • While this link may answer the question, link only answers are discouraged on Stack Overflow, you can improve this answer by taking vital parts of the link and putting it into your answer, this makes sure your answer is still an answer if the link gets changed or removed :) – WhatsThePoint Oct 22 '18 at 07:58
1

Yo can simply write it to the file, and then read it from file with the help of AWS logs agent. Here is the link that explains how to configure your EC2 instance to do that.

Yahya Hussein
  • 8,767
  • 15
  • 58
  • 114
neckobik
  • 307
  • 1
  • 6
  • 13
  • 1
    While this link may assist in your answer to the question, you can improve this answer by taking vital parts of the link and putting it into your answer, this makes sure your answer is still an answer if the link gets changed or removed :) – WhatsThePoint Oct 22 '18 at 07:58