TomatoLog is based .NETCore platforms.

TomatoLog

TomatoLog is based .NETCore platforms.

The TomatoLog is a middleware that includes client, server, very easy to use and deploy.

The client realized ILoggerFactory, using the service can be used after implantation success, the invasion of the business is very small, also supports writing log stream through client calls.

TomatoLog client and server are based on the current version .NETCore client provides three log stream transmission, currently realized Redis / RabbitMQ / Kafka flow. If you wish to use non-.NETCore client platform, you can open your own language other third-party clients, by implementing TomatoLog transport protocol to transfer data to the pipe (Redis / RabbitMQ / Kafka) can be.

TomatoLog server also provides three ways to store logs, namely File, MongoDB, Elasticsearch, storage can be specified by the configuration file. In TomatoLog the service side, we also offer a Web console, you can query the log, search through the console, the service filter is configured, alert configuration, notification, etc., which, alarm notification method can be used there are: SMS and Email in two ways, however, it is essentially an SMS Http request, via SMS configuration, it may be implemented to provide a gateway interface to send a notification to all Http.

TomatoLog System Architecture

Get Started

Using Client

Select any one of the following client

Install-Package TomatoLog.Client.Redis
Install-Package TomatoLog.Client.RabbitMQ Install-Package TomatoLog.Client.Kafka

TomatoLog client profile appsetting.json

{
  "TomatoLog": {
    "LogLevel": "Information",
    "ProjectLabel": "Example", "ProjectName": "Example", "SysOptions": { "EventId": true, "IP": true, "IPList": true, "MachineName": true, "ProcessId": true, "ProcessName": true, "ThreadId": true, "Timestamp": true, "UserName": true }, "Tags": null, "Version": "1.0.0", "Exchange": "TomatoLog-Exchange", "ExchangeType": "direct", "Host": "127.0.0.1", "Password": "123456", "Port": 5672, "QueueName": "TomatoLog-Queue", "RouteKey": "All", "UserName": "lgx", "vHost": "TomatoLog" } }

Service injection

public void ConfigureServices(IServiceCollection services)
{
    services.AddSingleton<ITomatoLogClient>(factory =>
    {
        var options = this.Configuration.GetSection("TomatoLog").Get<EventRabbitMQOptions>(); var client = new TomatoLogClientRabbitMQ(options); return client; }); ... }

Configuration is enabled

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory factory, ITomatoLogClient logClient) { factory.UseTomatoLogger(logClient); ... }

Use TomatoLogClient

[Route("api/[controller]")]
[ApiController]
public class HomeController : ControllerBase { private readonly ITomatoLogClient logClient; private readonly ILogger logger; public HomeController(ILogger<HomeController> logger, ITomatoLogClient logClient) { this.logger = logger; this.logClient = logClient; } [HttpGet] public async Task<ActionResult<IEnumerable<string>>> Get() { // Used by ILogger this.logger.LogError("测试出错了"); // Used By ITomatoLogClient try { await this.logClient.WriteLogAsync(1029, LogLevel.Warning, "Warning Infomation", "Warning Content", new { LastTime = DateTime.Now, Tips = "Warning" }); throw new NotSupportedException("NotSupported Media Type"); } catch (Exception ex) { await ex.AddTomatoLogAsync(); } return new string[] { "value1", "value2" }; } }

Deployment server

First, download the compressed file server  version of the preview  , the archive contains only the files necessary to run the project, hosted on the server of the server must be in accordance DotNET Core SDK 2.2+

Next, unzip the file, modify appsetting.Environment.json file servers are configured, the server will be configured to deploy on your server, you can select IIS or other escrow for the TomatoLog, the server runs by default port: 20272.

Edit the server configuration file

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug", "System": "Information", "Microsoft": "Information" } }, "TomatoLog": { "Cache-Redis": null, // 过滤器会使用该分布式缓存进行策略考量,如果有配置 "Config": { "SysConfig": "Config/SysConfig.json" // 系统配置文件,可通过Web控制台进行配置 }, "Storage": { "Type": "ToFile", //ToFile/ToES/ToMongoDB 可以选择的存储方式 "File": "D:\\TomatoLog\\Storage", // 如果Type选择了 ToFile ,则这里必须指定绝对路径 "ES": "http://127.0.0.1:9200/", // 如果Type选择了ToES,这里必须配置 Elasticsearch 服务地址 "MongoDB": "mongodb://root:[email protected]:27017/admin" //如果Type选择了ToMongoDB,这里必须配置 ToMongoDB 数据库链接 }, "Flow": { "Type": "RabbitMQ", // Redis/RabbitMQ/Kafaka 这里指定客户端和服务器的传输管道类型,两端配置必须一致 "Redis": { "Connection": null, "Channel": "TomatoLogChannel" }, "RabbitMQ": { // 如果使用了 RabbitMQ,则必须配置该节点 "Host": "127.0.0.1", "Port": 5672, "UserName": "root", "Password": "123456", "vHost": "TomatoLog", "Exchange": "TomatoLog-Exchange", "ExchangeType": "direct", "QueueName": "TomatoLog-Queue", "RouteKey": "All", "Channels": 1 // 运行的消息队列实例数量 }, "Kafka": { "Group": "TomatoLogServer", "BootstrapServers": "127.0.0.1:9092", "Topic": "TomatoLog" } } } } 

Tomato log server console look like

Open the address in your browser: http: // localhost: 20272 /

Home to see the log list

Log details pop View details, log search, support ES / MongoDB / File Search

Global log processing, alarm configuration

Detailed log processing for a single project, alarm configuration

A pack, run anywhere

Whether from the project structure or solution, it is the most beautiful I have emphasized the simple fundamental requirement for the content of the solution may seem a lot, but you only need one client demand references on it, especially the server, full-application stations are packaged in a .NETCore, the alarm program configurations are stored in the configuration file, no database support.

TomatoLog

TomatoLog is based .NETCore platforms.

The TomatoLog is a middleware that includes client, server, very easy to use and deploy.

The client realized ILoggerFactory, using the service can be used after implantation success, the invasion of the business is very small, also supports writing log stream through client calls.

TomatoLog client and server are based on the current version .NETCore client provides three log stream transmission, currently realized Redis / RabbitMQ / Kafka flow. If you wish to use non-.NETCore client platform, you can open your own language other third-party clients, by implementing TomatoLog transport protocol to transfer data to the pipe (Redis / RabbitMQ / Kafka) can be.

TomatoLog server also provides three ways to store logs, namely File, MongoDB, Elasticsearch, storage can be specified by the configuration file. In TomatoLog the service side, we also offer a Web console, you can query the log, search through the console, the service filter is configured, alert configuration, notification, etc., which, alarm notification method can be used there are: SMS and Email in two ways, however, it is essentially an SMS Http request, via SMS configuration, it may be implemented to provide a gateway interface to send a notification to all Http.

TomatoLog System Architecture

Get Started

Using Client

Select any one of the following client

Install-Package TomatoLog.Client.Redis
Install-Package TomatoLog.Client.RabbitMQ Install-Package TomatoLog.Client.Kafka

TomatoLog client profile appsetting.json

{
  "TomatoLog": {
    "LogLevel": "Information",
    "ProjectLabel": "Example", "ProjectName": "Example", "SysOptions": { "EventId": true, "IP": true, "IPList": true, "MachineName": true, "ProcessId": true, "ProcessName": true, "ThreadId": true, "Timestamp": true, "UserName": true }, "Tags": null, "Version": "1.0.0", "Exchange": "TomatoLog-Exchange", "ExchangeType": "direct", "Host": "127.0.0.1", "Password": "123456", "Port": 5672, "QueueName": "TomatoLog-Queue", "RouteKey": "All", "UserName": "lgx", "vHost": "TomatoLog" } }

Service injection

public void ConfigureServices(IServiceCollection services)
{
    services.AddSingleton<ITomatoLogClient>(factory =>
    {
        var options = this.Configuration.GetSection("TomatoLog").Get<EventRabbitMQOptions>(); var client = new TomatoLogClientRabbitMQ(options); return client; }); ... }

Configuration is enabled

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory factory, ITomatoLogClient logClient) { factory.UseTomatoLogger(logClient); ... }

Use TomatoLogClient

[Route("api/[controller]")]
[ApiController]
public class HomeController : ControllerBase { private readonly ITomatoLogClient logClient; private readonly ILogger logger; public HomeController(ILogger<HomeController> logger, ITomatoLogClient logClient) { this.logger = logger; this.logClient = logClient; } [HttpGet] public async Task<ActionResult<IEnumerable<string>>> Get() { // Used by ILogger this.logger.LogError("测试出错了"); // Used By ITomatoLogClient try { await this.logClient.WriteLogAsync(1029, LogLevel.Warning, "Warning Infomation", "Warning Content", new { LastTime = DateTime.Now, Tips = "Warning" }); throw new NotSupportedException("NotSupported Media Type"); } catch (Exception ex) { await ex.AddTomatoLogAsync(); } return new string[] { "value1", "value2" }; } }

Deployment server

First, download the compressed file server  version of the preview  , the archive contains only the files necessary to run the project, hosted on the server of the server must be in accordance DotNET Core SDK 2.2+

Next, unzip the file, modify appsetting.Environment.json file servers are configured, the server will be configured to deploy on your server, you can select IIS or other escrow for the TomatoLog, the server runs by default port: 20272.

Edit the server configuration file

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug", "System": "Information", "Microsoft": "Information" } }, "TomatoLog": { "Cache-Redis": null, // 过滤器会使用该分布式缓存进行策略考量,如果有配置 "Config": { "SysConfig": "Config/SysConfig.json" // 系统配置文件,可通过Web控制台进行配置 }, "Storage": { "Type": "ToFile", //ToFile/ToES/ToMongoDB 可以选择的存储方式 "File": "D:\\TomatoLog\\Storage", // 如果Type选择了 ToFile ,则这里必须指定绝对路径 "ES": "http://127.0.0.1:9200/", // 如果Type选择了ToES,这里必须配置 Elasticsearch 服务地址 "MongoDB": "mongodb://root:[email protected]:27017/admin" //如果Type选择了ToMongoDB,这里必须配置 ToMongoDB 数据库链接 }, "Flow": { "Type": "RabbitMQ", // Redis/RabbitMQ/Kafaka 这里指定客户端和服务器的传输管道类型,两端配置必须一致 "Redis": { "Connection": null, "Channel": "TomatoLogChannel" }, "RabbitMQ": { // 如果使用了 RabbitMQ,则必须配置该节点 "Host": "127.0.0.1", "Port": 5672, "UserName": "root", "Password": "123456", "vHost": "TomatoLog", "Exchange": "TomatoLog-Exchange", "ExchangeType": "direct", "QueueName": "TomatoLog-Queue", "RouteKey": "All", "Channels": 1 // 运行的消息队列实例数量 }, "Kafka": { "Group": "TomatoLogServer", "BootstrapServers": "127.0.0.1:9092", "Topic": "TomatoLog" } } } } 

Tomato log server console look like

Open the address in your browser: http: // localhost: 20272 /

Home to see the log list

Log details pop View details, log search, support ES / MongoDB / File Search

Global log processing, alarm configuration

Detailed log processing for a single project, alarm configuration

A pack, run anywhere

Whether from the project structure or solution, it is the most beautiful I have emphasized the simple fundamental requirement for the content of the solution may seem a lot, but you only need one client demand references on it, especially the server, full-application stations are packaged in a .NETCore, the alarm program configurations are stored in the configuration file, no database support.

Guess you like

Origin www.cnblogs.com/Leo_wl/p/11752763.html