优购物官方网站地址,wordpress如何创建项目,aplkey怎么注册域名,手机app怎么开发的TomatoLogTomatoLog 是一个基于 .NETCore 平台的产品。The TomatoLog 是一个中间件#xff0c;包含客户端、服务端#xff0c;非常容易使用和部署。客户端实现了ILoggerFactory#xff0c;使用服务注入成功后即可使用#xff0c;对业务入侵非常小#xff0c;也支持通过客户… TomatoLogTomatoLog 是一个基于 .NETCore 平台的产品。The TomatoLog 是一个中间件包含客户端、服务端非常容易使用和部署。客户端实现了ILoggerFactory使用服务注入成功后即可使用对业务入侵非常小也支持通过客户端调用写入日志流。TomatoLog 的客户端和服务端目前都是基于 .NETCore 版本,客户端提供了三种日志流传输方式目前实现了 Redis/RabbitMQ/Kafka 流。如果希望使用非 .NETCore 平台的客户端你可以自己开放其它第三方语言的客户端通过实现 TomatoLog 传输协议将数据传送到管道(Redis/RabbitMQ/Kafka)中即可。TomatoLog 服务端还提供了三种存储日志的方式分别是 File、MongoDB、Elasticsearch存储方式可以通过配置文件指定。在 TomatoLog 服务端我们还提供了一个Web 控制台通过该控制台可以对日志进行查询、搜索对服务过滤器进行配置警报配置、通知发送等等其中可使用的警报通知方式有SMS 和 Email 两种方式但是SMS 其本质是一个 Http 请求通过 SMS 的配置可以实现向所有提供了 Http 接口的网关发送通知。TomatoLog 系统架构Get Started使用客户端选择安装以下客户端中的任意一项Install-Package TomatoLog.Client.Redis
Install-Package TomatoLog.Client.RabbitMQ
Install-Package TomatoLog.Client.KafkaTomatoLog客户端配置文件 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 }
}服务注入public void ConfigureServices(IServiceCollection services)
{ services.AddSingletonlt;ITomatoLogClientgt;(factory gt; { var options this.Configuration.GetSection(TomatoLog).Getlt;EventRabbitMQOptionsgt;(); var client new TomatoLogClientRabbitMQ(options); return client; }); ...
}配置启用public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory factory, ITomatoLogClient logClient)
{ factory.UseTomatoLogger(logClient); ...
}使用 TomatoLogClient[Route(api/[controller])]
[ApiController]
public class HomeController : ControllerBase
{ private readonly ITomatoLogClient logClient; private readonly ILogger logger; public HomeController(ILoggerlt;HomeControllergt; logger, ITomatoLogClient logClient) { this.logger logger; this.logClient logClient; } [HttpGet] public async Tasklt;ActionResultlt;IEnumerablelt;stringgt;gt;gt; 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 }; }
}部署服务端首先下载服务端压缩包文件 版本预览 该压缩包仅包含项目运行必需文件托管该服务端的服务器上必须按照 DotNET Core SDK 2.2接下来解压文件修改 appsetting.Environment.json 文件将服务器进行配置将配置好的服务端部署到你的服务器上可以为 TomatoLog 选择 IIS 或者其它托管方式服务端默认运行端口为20272.编辑服务端配置文件{ 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:root127.0.0.1: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 } } }
}番茄日志服务端控制台长什么样在浏览器中打开地址http://localhost:20272/首页看日志列表日志详情、弹出查看详情、日志搜索、支持ES/MongoDB/File搜索全局日志处理、警报配置针对单个项目的详细日志处理、警报配置一次打包到处运行不管是从项目结构还是解决方案我都强调简单就是最美的根本要求解决方案的内容虽然看起来很多但是你也只需要按需引用其中一个客户端就可以了服务端更是如此全站都打包在一个 .NETCore 的应用程序中程序的警报配置都是存储在配置文件中的无需数据库支持。