An open API service indexing awesome lists of open source software.

https://github.com/k-society/ksociety.log

Centralized log system.
https://github.com/k-society/ksociety.log

log logger logging rabbitmq serilog serilog-sink

Last synced: 8 months ago
JSON representation

Centralized log system.

Awesome Lists containing this project

README

          

[![Logo](https://github.com/K-Society/KSociety.Log/blob/master/docs/K-Society__Logo_vs-negative.png)](https://github.com/K-Society)

[![build status](https://img.shields.io/github/actions/workflow/status/K-Society/KSociety.Log/build.yml?branch=develop)](https://github.com/K-Society/KSociety.Log/actions/workflows/build.yml?query=branch%3Adevelop) [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.Serilog.Sinks.RabbitMq)](https://www.nuget.org/profiles/K-Society)
![GitHub all releases](https://img.shields.io/github/downloads/K-Society/KSociety.Log/total)

# KSociety.Log - Log System

## Introduction

This is the README file for KSociety.Log.
KSociety.Log is a .NET 8.0 centralized log system, to work properly it needs [RabbitMQ](https://github.com/K-Society/KSociety.RabbitMQ.Install/releases).

### Examples

[Here](https://github.com/K-Society/KSociety.Example) you can find several examples.

## For Linux
Copy KSociety.Log.Srv.Host.service and KSociety.Log.Pre.Web.App.service files to /etc/systemd/system/ directory.

## Port numbers
- Log Server: 60500
- Log Presenter: 61000

## Get Packages

You can get KSociety.Log.Serilog.Sinks.RabbitMq by [grabbing the latest NuGet package](https://www.nuget.org/packages/KSociety.Log.Serilog.Sinks.RabbitMq/).

## Get Started

If you work in localhost you will need to install the following applications:
- [RabbitMQ](https://github.com/K-Society/KSociety.RabbitMQ.Install/releases)
- [KSociety.Log](https://github.com/K-Society/KSociety.Log/releases)

In your project install KSociety.Log.Serilog.Sinks.RabbitMq nuget package.
Remember to set the "Copy to Output Directory" option of the appsettings.json file to "Copy if newer".\
Add the following section in the appsettings.json file of your application:

```json
"Serilog": {
"Using": [
"KSociety.Log.Serilog.Sinks.RabbitMq"
],
"MinimumLevel": {
"Default": "Verbose",
"Override": {
"Microsoft": "Warning",
"System": "Warning",
"Grpc": "Error",
"ProtoBuf": "Error"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"outputTemplate": "[{Timestamp:yyyy-mm-dd HH:mm:ss.fff} {Level:u3}] [{MachineName}] [{SourceContext}] {Message}{NewLine:1}{Exception:1}"
}
},
{
"Name": "RabbitMq",
"Args": {
"mqHostName": "localhost",
"mqUserName": "KSociety",
"mqPassword": "KSociety",
"brokerName": "k-society_log",
"exchangeType": "Direct",
"exchangeDurable": false,
"exchangeAutoDelete": true,
"queueDurable": false,
"queueExclusive": false,
"queueAutoDelete": true,
"batchPostingLimit": 50,
"period": "00:00:02",
"textFormatter": "KSociety.Log.Serilog.Sinks.RabbitMq.Sinks.RabbitMq.Output.LogEventFormatter, KSociety.Log.Serilog.Sinks.RabbitMq"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithProcessId",
"WithThreadId"
],
"Properties": {
"ApplicationName": "your application name"
}
}
```
Add the following lines of code at the beginning of the main:

```csharp
KSociety.Log.Serilog.Sinks.RabbitMq.ProtoModel.Configuration.ProtoBufConfiguration();

var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();

global::Serilog.Log.Logger = new LoggerConfiguration().ReadFrom.Configuration(configuration).CreateLogger();
```

All log messages generated by your application will be sent to RabbitMQ and forwarded to the KSociety.Log.Srv.Host service.\
KSociety.Log.Srv.Host service will:
- forward the log messages to the web application KSociety.Log.Pre.Web.App for real-time viewing
- write the log messages to a file

### 0. Installer
The installer.

| GitHub Repository | NuGet | Download |
| ------------- | ------------- | ------------- |

### 1. Presentation
The presentation layer.

| GitHub Repository | NuGet | Download |
| ------------- | ------------- | ------------- |

### 1.1 Presentation - Web
| GitHub Repository | NuGet | Download |
| ------------- | ------------- | ------------- |
| [KSociety.Log.Pre.Web.App](https://github.com/K-Society/KSociety.Log/tree/master/src/01/01/Web/KSociety.Log.Pre.Web.App) | | |

### 2. Service
The service layer.

| GitHub Repository | NuGet | Download |
| ------------- | ------------- | ------------- |
| [KSociety.Log.Srv.Agent](https://github.com/K-Society/KSociety.Log/tree/master/src/01/02/KSociety.Log.Srv.Agent) | [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.Srv.Agent)](https://www.nuget.org/packages/KSociety.Log.Srv.Agent) | ![NuGet](https://img.shields.io/nuget/dt/KSociety.Log.Srv.Agent) |
| [KSociety.Log.Srv.Behavior](https://github.com/K-Society/KSociety.Log/tree/master/src/01/02/KSociety.Log.Srv.Behavior) | [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.Srv.Behavior)](https://www.nuget.org/packages/KSociety.Log.Srv.Behavior) | ![NuGet](https://img.shields.io/nuget/dt/KSociety.Log.Srv.Behavior) |
| [KSociety.Log.Srv.Contract](https://github.com/K-Society/KSociety.Log/tree/master/src/01/02/KSociety.Log.Srv.Contract) | [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.Srv.Contract)](https://www.nuget.org/packages/KSociety.Log.Srv.Contract) | ![NuGet](https://img.shields.io/nuget/dt/KSociety.Log.Srv.Contract) |
| [KSociety.Log.Srv.Dto](https://github.com/K-Society/KSociety.Log/tree/master/src/01/02/KSociety.Log.Srv.Dto) | [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.Srv.Dto)](https://www.nuget.org/packages/KSociety.Log.Srv.Dto) | ![NuGet](https://img.shields.io/nuget/dt/KSociety.Log.Srv.Dto) |

### 2.1 Service - Host

| GitHub Repository | NuGet | Download |
| ------------- | ------------- | ------------- |
| [KSociety.Log.Srv.Host](https://github.com/K-Society/KSociety.Log/tree/master/src/01/02/Host/KSociety.Log.Srv.Host) | | |

### 3. Application
The application layer.

| GitHub Repository | NuGet | Download |
| ------------- | ------------- | ------------- |
| [KSociety.Log.App.Dto](https://github.com/K-Society/KSociety.Log/tree/master/src/01/03/KSociety.Log.App.Dto) | [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.App.Dto)](https://www.nuget.org/packages/KSociety.Log.App.Dto) | ![NuGet](https://img.shields.io/nuget/dt/KSociety.Log.App.Dto) |
| [KSociety.Log.App.ReqHdlr](https://github.com/K-Society/KSociety.Log/tree/master/src/01/03/KSociety.Log.App.ReqHdlr) | [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.App.ReqHdlr)](https://www.nuget.org/packages/KSociety.Log.App.ReqHdlr) | ![NuGet](https://img.shields.io/nuget/dt/KSociety.Log.App.ReqHdlr) |

### 4. Business
| GitHub Repository | NuGet | Download |
| ------------- | ------------- | ------------- |
| [KSociety.Log.Biz](https://github.com/K-Society/KSociety.Log/tree/master/src/01/04/KSociety.Log.Biz) | [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.Biz)](https://www.nuget.org/packages/KSociety.Log.Biz) | ![NuGet](https://img.shields.io/nuget/dt/KSociety.Log.Biz) |
| [KSociety.Log.Biz.Event](https://github.com/K-Society/KSociety.Log/tree/master/src/01/04/KSociety.Log.Biz.Event) | [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.Biz.Event)](https://www.nuget.org/packages/KSociety.Log.Biz.Event) | ![NuGet](https://img.shields.io/nuget/dt/KSociety.Log.Biz.Event) |

### Sink
| GitHub Repository | NuGet | Download |
| ------------- | ------------- | ------------- |
| [KSociety.Log.Serilog.Sinks.Grpc](https://github.com/K-Society/KSociety.Log/tree/master/src/01/Sink/KSociety.Log.Serilog.Sinks.Grpc) | [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.Serilog.Sinks.Grpc)](https://www.nuget.org/packages/KSociety.Log.Serilog.Sinks.Grpc) | ![NuGet](https://img.shields.io/nuget/dt/KSociety.Log.Serilog.Sinks.Grpc) |
| [KSociety.Log.Serilog.Sinks.RabbitMq](https://github.com/K-Society/KSociety.Log/tree/master/src/01/Sink/KSociety.Log.Serilog.Sinks.RabbitMq) | [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.Serilog.Sinks.RabbitMq)](https://www.nuget.org/packages/KSociety.Log.Serilog.Sinks.RabbitMq) | ![NuGet](https://img.shields.io/nuget/dt/KSociety.Log.Serilog.Sinks.RabbitMq) |
| [KSociety.Log.Serilog.Sinks.SignalR](https://github.com/K-Society/KSociety.Log/tree/master/src/01/Sink/KSociety.Log.Serilog.Sinks.SignalR) | [![NuGet](https://img.shields.io/nuget/v/KSociety.Log.Serilog.Sinks.SignalR)](https://www.nuget.org/packages/KSociety.Log.Serilog.Sinks.SignalR) | ![NuGet](https://img.shields.io/nuget/dt/KSociety.Log.Serilog.Sinks.SignalR) |

## License
The project is under Microsoft Reciprocal License [(MS-RL)](http://www.opensource.org/licenses/MS-RL)

## Dependencies

List of technologies, frameworks and libraries used for implementation:

- [.NET 8](https://dotnet.microsoft.com/download/dotnet/8.0)(platform). Note for Visual Studio users: **VS 2022** is required.
- [Autofac](https://autofac.org/) (Inversion of Control Container)
- [protobuf-net](https://github.com/protobuf-net/protobuf-net) (protobuf-net is a contract based serializer for .NET code)
- [RabbitMQ.Client](https://www.rabbitmq.com/dotnet.html) (The RabbitMQ .NET client is an implementation of an AMQP 0-9-1 client library for C#)
- [Serilog](https://serilog.net/) (structured logging)
- [KSociety.Base.App.Shared](https://github.com/K-Society/KSociety.Base/tree/master/src/01/03/KSociety.Base.App.Shared) ()
- [KSociety.Base.EventBusRabbitMQ](https://github.com/K-Society/KSociety.Base/tree/master/src/01/KSocietyBaseEventBus/KSociety.Base.EventBusRabbitMQ) ()
- [KSociety.Base.Srv.Agent](https://github.com/K-Society/KSociety.Base/tree/master/src/01/02/KSociety.Base.Srv.Agent) ()
- [KSociety.Base.Srv.Host.Shared](https://github.com/K-Society/KSociety.Base/tree/master/src/01/02/KSociety.Base.Srv.Shared) ()