Can't use environment variable to get SharedKey
Closed this issue · 2 comments
Trying to set the shared key using an environment variable like below:
<appender name="Log4ALAAppender" type="Log4ALA.Log4ALAAppender, Log4ALA">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
<workspaceId value="${MY_PREFIX_ALAWorkspaceId}" />
<SharedKey value="${MY_PREFIX_ALASharedKey}" />
<logType value="my_log_type" />
</appender>
I keep getting this error:
[Log4ALAAppender] - Unable to activate Log4ALAAppender: [The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.]
I know the shared key I have is good because if I put it directly in the config it works fine. Not sure if I need to escape the value somehow when I create the environment variable.
Details:
.netcoreapp 2.1
Log4ALA 2.3.6
Developing on Windows 10 and deploying to Ubuntu Docker container
Ok so I forked your repo and started debugging and I realized that the Log4ALA appender doesn't interpret those environment variables at all. So the SharedKey is literally getting set to ${MY_PREFIX_ALASharedKey} as well as the workspaceId is getting set to ${MY_PREFIX_ALAWorkspaceId}.
So I guess this is really more of a feature request to add support for environment variables in the configuration now.
Hi @jorjenava,
in Case of .netcoreapp please use appsettings.json in combination with log4net.config and try the following:
log4net.config:
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
...
...
<appender name="Log4ALAAppender" type="Log4ALA.Log4ALAAppender, Log4ALA" />
<logger name="Log4ALALogger" additivity="false">
<appender-ref ref="Log4ALAAppender" />
</logger>
...
...
</log4net>
appsettings.json:
{
...
...
"Log4ALAAppender": {
"logType": "YOUR_LOG_TYPE",
"logMessageToFile": "false",
"batchSizeInBytes": "30000",
"batchWaitMaxInSec": "60"
}
...
...
}
and for example now the environment variables to set for workspaceId and SharedKey (environment variable with dotnetcore appsettings notation with ":" )
Log4ALAAppender:workspaceId
Log4ALAAppender:SharedKey