It's possible to read "credentials/sensitive info" from environment variables?
See original GitHub issueSerilog Settings Configuration(Serilog.Sinks.Datadog.Logs):
Sample:
"Serilog": {
"Using": [ "Serilog.Sinks.Datadog.Logs" ],
"MinimumLevel": "Debug",
"WriteTo": [
{ "Name": "Console" },
{
"Name": "DatadogLogs",
"Args": {
//"apiKey": "<API_KEY>",
"apiKey": "${READ_IT_FROM_ENVIRONMENT_VARIABLE:VARIABLE_NAME}", //<- This approach does not exist/does not work.
}
}
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ],
"Properties": {
"Application": "Sample"
}
}
We have something similar in NLog: ${environment:ENVIRONMENT_VARIABLE_NAME}
.
Sample:
NLog.config(NLog.Targets.ElasticSearch)
...
<target xsi:type="ElasticSearch"
...
username="${environment:ELASTICSEARCH_USER}"
password="${environment:ELASTICSEARCH_PASSWORD}"
layout="${verbose}">
<field name="host" layout="${machinename}"/>
</target>
...
Issue Analytics
- State:
- Created 8 months ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Is it secure to store passwords as environment variables ...
There's no way to store an un-encrypted password securely. Now which of environment variables vs. config files is more "secure" is perhapsĀ ...
Read more >Keep your code secure by using environment variables ...
Keep your credentials safe. The first reason is the most important by far: environment variables keep your credentials save. We want to preventĀ ......
Read more >Is it unsafe to use environmental variables for secret data?
In general storing secrets in environment variables does have some downsides, as Diogo says in his post. Generically, for platforms likeĀ ...
Read more >Analyzing the Hidden Danger of Environment Variables ...
This is because this practice is easy to implement and it could be dangerous if any confidential information is stored inside, leaked, and/orĀ ......
Read more >Handling Passwords and Secret Keys using Environment ...
The safest way to handle your secret keys/password is saving them in envirnoment variables. In this post we will learn how to save...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@nblumhardtās answer is right, you need to set the
Serilog__WriteTo__1__Args__apiKey
environment variable in order to override the value from theappsettings.json
file.The
__1__
is the (zero-based) index in theWriteTo
array, itās indeed awkward and error prone if you reorder your sinks in the configuration file.Official documentation:
Sample.csproj:
Program.cs:
Run this sample code with the
Serilog__WriteTo__1__Args__apiKey
environment variable set to your API key and you should see your log in Datadog.Itās not a Serilog feature so docs.microsoft.com (IIRC) would be the place to find it but I wasnāt able to track anything down with a quick skim. Placeholder Provider looks like another good option š