'Simple logging in .NET Core app on Elastic Beanstalk
I'm just starting to put some ASP.NET Core apps on Elastic Beanstalk. I want to do some simple logging initially just to track down some issues. I normally use Serilog, but at this point, I just need to get some info out to a log that I can view.
I see that it captures exceptions in /var/log/web.stdout.log (running on Linux).
Can I just have Serilog's File sink write to one of these files?
I will eventually implement Cloudwatch, but right now I'm looking for something simple.
Solution 1:[1]
You can't write direct into /var/log/web.stdout.log
as the file is owned by root
, and your app executes under webapp
user. You will get access denied if you try to modify the log file directly.
But you can tell EB which log files, specific to your application, to include in its bundles. This is done through .ebextensions
. Specifically, you can have a config file .ebextensions/mylogfiles.config
with the exemplary content of:
files:
"/opt/elasticbeanstalk/config/private/logtasks/bundle/mylogfiles.conf":
mode: "000644"
owner: root
group: root
content: |
/var/app/current/logs/*.log
where /var/app/current/log/*.log
would need to be adjusted to how your application store its logs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Shashank Shekhar |