Use NLog in .Net Core and AWS Lambda
Logging is a very essential part of developing scalable and maintainable systems. This is more important when deploying to hosting platforms such as AWS, Azure and Google cloud.
AWS Lambda is a model where you no longer need to care which server your code is running on, making it entirely someone else’s problem. Your resources needed are scaled according to your needs.
Nlog is an open source log platform for the .NET framework. Through this platform, it is easy to produce and manage logs of an application. Nlog can be used for both .net core and other .net frameworks
- Install the NLog nuget package
- Create a file named NLogAWS.config in the project root folder with the following configuration. This file contains some values that you can customize the logger.
3. In the file properties set the copy to output property to copy always.
4. Update the LocalEntryPoint.cs file
5. Then just inject the ILogger class into the constructor and call any of the log methods.