This guide explains how to set up and configure logging in a .NET application, and how to send logs to Axiom.
AxiomLogs
.
Microsoft.AspNet.WebApi.Client
package to make HTTP requests to the Axiom API. Run the following command to install the package:
AxiomLogger.cs
in your project directory with the following content:
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable.Replace DATASET_NAME
with the name of the Axiom dataset where you want to send data.Replace AXIOM_DOMAIN
with api.axiom.co
if your organization uses the US region, and with api.eu.axiom.co
if your organization uses the EU region. For more information, see Regions.Program.cs
file and replace its contents with the following code:
axiomlogs.csproj
file is configured with the package reference. The file should look like this:
Log sent successfully.
for each log entry.
Serilog
, Serilog.Sinks.Http
, Serilog.Formatting.Elasticsearch
and Serilog.Formatting.Json
packages.
Program.cs
or a startup configuration file, set up Serilog to use the HTTP sink. Configure the sink to point to the Axiom ingestion API endpoint.
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable.Replace DATASET_NAME
with the name of the Axiom dataset where you want to send data.Replace AXIOM_DOMAIN
with api.axiom.co
if your organization uses the US region, and with api.eu.axiom.co
if your organization uses the EU region. For more information, see Regions.axiomlogs.csproj
file is configured with the package references. The file should look like this:
NLog.config
file or configuring it programmatically. Here is an example configuration for NLog
using an HTTP target:
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable.Replace DATASET_NAME
with the name of the Axiom dataset where you want to send data.Replace AXIOM_DOMAIN
with api.axiom.co
if your organization uses the US region, and with api.eu.axiom.co
if your organization uses the EU region. For more information, see Regions.NLog
. In your Program.cs
file:
axiomlogs.csproj
file is configured with the package references. The file should look like this: