Web349.Logging
0.1.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Web349.Logging --version 0.1.1
NuGet\Install-Package Web349.Logging -Version 0.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Web349.Logging" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Web349.Logging --version 0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Web349.Logging, 0.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Web349.Logging as a Cake Addin
#addin nuget:?package=Web349.Logging&version=0.1.1
// Install Web349.Logging as a Cake Tool
#tool nuget:?package=Web349.Logging&version=0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Web349 Logging Library
This .NET Core 6 library contains the logging functionality used throughout Web349's internal and external projects. Contains a powerful Datadog logger.
ENV variable configuration
Required | Name | Type | Default value | Description |
---|---|---|---|---|
✅ | WEB349_LOGGING_DATADOG_APIKEY |
string |
Your Datadog API key | |
✅ | WEB349_LOGGING_DATADOG_SITE |
string |
The Datadog site to send logs to. Must be any of the following values: US1 , US3 , US5 , EU , AP1 , US1_GOV |
|
✅ | WEB349_LOGGING_LOGLEVEL |
string |
The log level. Must be any of the following values: Silent , Fatal , Error , Warning , Information , Debug , Verbose |
|
WEB349_LOGGING_DATADOG_SOURCE |
string |
Fills the Source field in Datadog | ||
WEB349_LOGGING_DATADOG_SERVICE |
string |
Fills the Service field in Datadog | ||
WEB349_LOGGING_DATADOG_HOST |
string |
Fills the Host field in Datadog | ||
WEB349_LOGGING_DATADOG_COMPRESSLOGS |
bool |
true |
Set to true to enable gzip compression |
|
WEB349_LOGGING_DATADOG_BATCH_SIZE |
int |
10 |
The maximum size of a single log event batch. | |
WEB349_LOGGING_DATADOG_BATCH_AGE |
int |
5 |
The maximum age, in seconds, of a single log event batch that has not reached its maximum batch size | |
WEB349_LOGGING_DATADOG_HTTPCLIENT_TIMEOUT |
int |
10 |
Underlying HttpClient timeout in seconds |
|
WEB349_LOGGING_SLACK_HTTPCLIENT_TIMEOUT |
int |
10 |
Underlying HttpClient timeout in seconds for calling the registered Webhook URL |
|
WEB349_LOGGING_SLACK_WEBHOOKURL_<NAME> |
string |
A SlackLogger needs a name argument in its constructor that should match up with this ENV var |
||
WEB349_LOGGING_DISPATCHER_DELAY_IDLE |
int |
1000 |
The delay, in miliseconds, for the log batch dispatcher to wait in between polls while idling | |
WEB349_LOGGING_DISPATCHER_DELAY_ACTIVE |
int |
100 |
The delay, in miliseconds, for the log batch dispatcher to wait in between polls while processing log events |
Requirements
- .NET Core 6 Download at dot.net
System.Text.Json
for JSON serialization
Notes
- Each instance of a
Logger
class creates its own contextlogger.Context
for identification purposes. - While technically possible, multiple threads should not share the same
Logger
instance. - Each
Logger
context keeps track of anint64
Event ID field.
Datadog logger usage examples
Logging regular information
Logger logger = new DatadogLogger();
logger.LogInformation("This is the message that will appear in Datadog");
Logging enriched information
Logger logger = new DatadogLogger();
logger
.Enrich("fieldName", 123)
.Enrich("anotherFieldName", "some string value")
.Enrich("foo", serializableBarObject)
.LogInformation("This is the message that will appear in Datadog, with the three fields enriched above");
Logging an Exception
Logger logger = new DatadogLogger();
try
{
throw new Exception("oops");
}
catch(Exception ex)
{
logger.LogError(ex.Message, ex);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.