Totallytech.LogService 1.0.2.6

Central Log System README

This README provides instructions on configuring a central log system in your ASP.NET Core application based on the specified location.

LogConfig Structure

The LogConfig structure defines the configuration settings for the central log system. Depending on the specified location, different configurations may be required.

"LogConfig": {
  "Location": "Seq",
  "LogFilePath": "/logs",
  "ServiceName": "Your Service Name",
  "LogEventLevel": 2,
  "SqlServerConnectionString": "",
  "SeqConfiguration": {
    "ServerUrl": "",
    "ApiKey": "",
    "HasMetrics":false,
    "otlpExporters":[
      {
        "Endpoint": "",
        "Protocol": "grpc",
        "Headers": "",
      }
    ]]

  },
  "RabbitMQConfig": {
    "HostName": "",
    "UserName": "",
    "Password": "",
    "VirtualHost": "/",
    "Port": 5671,
    "SslEnabled": false,
    "ServerName": "",
    "QueueName": ""
  },
  "ElasticConfiguration": {
    "Uri": ""
  }
}

📡 OpenTelemetry OTLP Exporter Headers

This document provides examples of how to configure OTLP exporter headers when sending telemetry data to popular observability backends. These headers are typically added when configuring OpenTelemetry in a .NET application using the OtlpExporterOptions.Headers property.


🔐 OTLP Exporter Headers Examples

Backend Header Example
Honeycomb x-honeycomb-team=your-api-key
New Relic api-key=YOUR_API_KEY
Grafana Cloud Authorization=Basic <base64 encoded user:token>
Elastic APM Authorization=Bearer YOUR_TOKEN

🛠️ Usage in .NET (C#)

.AddOtlpExporter(options =>
{
    options.Endpoint = new Uri("https://your-otlp-endpoint.com");
    options.Protocol = OtlpExportProtocol.Grpc;
    options.Headers = "Authorization=Bearer YOUR_TOKEN"; // Replace with your value
});


- **Protocol**: Protocol used for otlpExporters. Possible values:
  - `http/protobuf`
  - `grpc`

- **Location**: Location of the central log system. Possible values:
  - `Seq`
  - `File`
  - `RabbitMQ`
  - `SqlServer`
  - `ElasticDb`
- **LogEventLevel**: LogEventLevel of the central log system. Possible values (use numeric value default is Information (2)):
  - `0 ->Verbose`
  - `1 ->Debug`
  - `2 ->Information`
  - `3 ->Warning`
  - `4 ->Error`
  - `5 -> Fatal`
- **LogFilePath**: Path where log files are stored (if applicable).
- **ServiceName**: Name of your service.
- **LogEventLevel**: Level where log Event Level are defined (if applicable).
- **SqlServerConnectionString**: Connection string for SQL Server logging (if applicable).
- **SeqConfiguration**: Configuration for Seq logging (if applicable).
- **RabbitMQConfig**: Configuration for RabbitMQ logging (if applicable).
- **ElasticConfiguration**: Configuration for Elasticsearch logging (if applicable).

### Serilog Configuration

Use the provided middleware and setup in your application to configure Serilog with the specified settings.

```csharp
builder.Host.UseSerilog((context, loggerConfiguration) => 
    Logging.Library.Extensions.SeriLogger.Configure(context,builder.Services, loggerConfiguration));

Additional Middleware

Add middleware to log HTTP session information.

app.UseSerilogHttpSessionsLogging(HttpSessionInfoToLog.All);

Logging Response Body

If you want to log response bodies, set AllowGetResponse to true.

Conclusion

By following the steps outlined in this README and configuring the central log system based on the specified location, you can effectively manage and monitor logs for your ASP.NET Core application. This centralized logging approach helps streamline log management and enhances visibility into application behavior and performance.

No packages depend on Totallytech.LogService.

.NET 6.0

.NET 7.0

.NET 8.0

Version Downloads Last updated
1.0.2.20 62 7/16/2025
1.0.2.19 57 5/10/2025
1.0.2.18 9 5/10/2025
1.0.2.17 11 5/1/2025
1.0.2.16 14 4/30/2025
1.0.2.15 11 4/30/2025
1.0.2.14 12 4/30/2025
1.0.2.13 8 4/30/2025
1.0.2.12 12 4/30/2025
1.0.2.11 10 4/30/2025
1.0.2.10 12 4/29/2025
1.0.2.9 52 4/12/2025
1.0.2.8 11 4/12/2025
1.0.2.7 12 4/12/2025
1.0.2.6 7 4/12/2025
1.0.2.5 12 4/12/2025
1.0.2.4 16 2/20/2025
1.0.2.3 91 9/15/2024
1.0.2.2 39 6/15/2024
1.0.2.1 12 6/13/2024
1.0.2 87 6/9/2024
1.0.1 74 5/29/2024
1.0.0 77 5/26/2024