This is the README file for KSociety.Log. KSociety.Log is a .NET 8.0 centralized log system, to work properly it needs RabbitMQ.
Here you can find several examples.
Copy KSociety.Log.Srv.Host.service and KSociety.Log.Pre.Web.App.service files to /etc/systemd/system/ directory.
- Log Server: 60500
- Log Presenter: 61000
You can get KSociety.Log.Serilog.Sinks.RabbitMq by grabbing the latest NuGet package.
If you work in localhost you will need to install the following applications:
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:
"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:
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
The installer.
GitHub Repository | NuGet | Download |
---|
The presentation layer.
GitHub Repository | NuGet | Download |
---|
GitHub Repository | NuGet | Download |
---|---|---|
KSociety.Log.Pre.Web.App |
The service layer.
GitHub Repository | NuGet | Download |
---|---|---|
KSociety.Log.Srv.Agent | ||
KSociety.Log.Srv.Behavior | ||
KSociety.Log.Srv.Contract | ||
KSociety.Log.Srv.Dto |
GitHub Repository | NuGet | Download |
---|---|---|
KSociety.Log.Srv.Host |
The application layer.
GitHub Repository | NuGet | Download |
---|---|---|
KSociety.Log.App.Dto | ||
KSociety.Log.App.ReqHdlr |
GitHub Repository | NuGet | Download |
---|---|---|
KSociety.Log.Biz | ||
KSociety.Log.Biz.Event |
GitHub Repository | NuGet | Download |
---|---|---|
KSociety.Log.Serilog.Sinks.Grpc | ||
KSociety.Log.Serilog.Sinks.RabbitMq | ||
KSociety.Log.Serilog.Sinks.SignalR |
The project is under Microsoft Reciprocal License (MS-RL)
List of technologies, frameworks and libraries used for implementation:
- .NET 8(platform). Note for Visual Studio users: VS 2022 is required.
- Autofac (Inversion of Control Container)
- protobuf-net (protobuf-net is a contract based serializer for .NET code)
- RabbitMQ.Client (The RabbitMQ .NET client is an implementation of an AMQP 0-9-1 client library for C#)
- Serilog (structured logging)
- KSociety.Base.App.Shared ()
- KSociety.Base.EventBusRabbitMQ ()
- KSociety.Base.Srv.Agent ()
- KSociety.Base.Srv.Host.Shared ()