Logging into AWS CloudWatch using NLog
Logging into AWS CloudWatch using NLog
NLog has a target for writing log messages directly into AWS CloudWatch.
Nuget: AWS.Logger.Nlog
URL: https://github.com/aws/aws-logging-dotnet
The configuration is very simple and straightforward.
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
throwConfigExceptions="true">
<extensions>
<add assembly="NLog.AWS.Logger" />
</extensions>
<targets>
<target name="aws" type="AWSTarget" logGroup="NLog.ConfigExample" region="us-east-1"/>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="aws" />
</rules>
</nlog>
In the above config snippet, the important part has been emphasized in bold and italics. Include the extension via add assembly. Specify the logger type as "AWSTarget". Specify the logGroup name and region.
Have the proper permissions configured for the role associated with the EC2 instance from where the code will be running.
Comments
Post a Comment
Chime in!