aws / aws-logging-dotnet

.NET Libraries for integrating Amazon CloudWatch Logs with popular .NET logging libraries
Apache License 2.0
297 stars 133 forks source link

Nlog to aws cloudwatch not working when passing lookup values #192

Closed hareeshmakani closed 2 years ago

hareeshmakani commented 2 years ago
<?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"
      autoReload="true"
      internalLogLevel="info"
      internalLogFile="c:\LogsDemo\NLogs\internal-nlog.txt">

    <extensions>
        <add assembly="NLog.AWS.Logger" />
    </extensions>

    <targets>
        <target name="aws" type="AWSTarget" logGroup="NLog.ConfigExample2" profile="'${var:profile}'" region="'${var:region}'"/>        
    </targets>

    <rules>
        <logger name="*" minlevel="Info" writeTo="aws" />
    </rules>
</nlog>

The above code to log data into aws cloudwatch is not working when I try to pass region & profile values from startup class.

    LogManager.Configuration.Variables["region"] = "ap-south-1";
    LogManager.Configuration.Variables["profile"] = "default";

However when I hardcoded the values it's working.

<target name="aws" type="AWSTarget" logGroup="NLog.ConfigExample" profile="default" region="ap-south-1"/>
snakefoot commented 2 years ago

See also advice given here: https://github.com/NLog/NLog/issues/4841

ashishdhingra commented 2 years ago

Hi @hareeshmakani,

Good morning.

Thanks for posting the question.

Few things to note about dynamic variables:

Does the guidance shared by @snakefoot doesn't work for you. Based on 2nd point above, this issue doesn't appear to be an issue with the AWS.Logger.Nlog package (it is really a wrapper around NLog library), but rather investigation/guidance on how NLog configuration works.

Thanks, Ashish

github-actions[bot] commented 2 years ago

This issue has not received a response in 5 days. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.