1 Star 0 Fork 1

PasteCode / PasteLoggerBoard

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

PasteLoggerBoard

介绍

ELK如果对于你来说太大,那么可以试试这个PasteLoggerBoard,一款使用.netcore(基于ABP基础框架搭建)编写的日志收集系统,快速集成于现有系统,采用Postgresql+redis+rabbitmq的方式,收集程序的日志并显示报表,状态通知(推送webhook)等!

软件架构

.netcore6.0(EF)+postgresql(EF)+rabbitmq+redis 如果你使用其他数据库可以进行修改,首先需要你对EF有了解,会更改EF的数据库!

输入图片说明

安装教程

使用docker/podman正常安装即可,也可以使用PasteSpider(使用文档 https://soft.pastecode.cn/Home/Docs/spider/0 )进行快速部署(关键是后面自己改代码了,可以一键发布升级)!LoggerBoardManage文件夹里面的是前端文件,本系统采用前后端分离,如果要新增功能,建议安装PasteBuilder(使用文档 https://soft.pastecode.cn/Article/18 )代码生成器,这样可以快速的为新模块生成对应的代码!

使用说明

参考demo.md文件,信息如下

引入

    <PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
    <PackageReference Include="Serilog.Enrichers.ClientInfo" Version="2.0.3" />
    <PackageReference Include="Serilog.Sinks.RabbitMQ" Version="6.0.0" />

Program.cs

                Configuration = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
                .AddEnvironmentVariables()
                .Build();
            var configlist = Configuration.AsEnumerable();
            var result = configlist.Where(x => x.Key.StartsWith("SerilogRabbitConfig:")).ToDictionary(x => x.Key.Replace("SerilogRabbitConfig:", ""), x => x.Value);
            if (result != null && result.Count > 0)
            {
                var _serilogConfig = Newtonsoft.Json.JsonConvert.DeserializeObject<RabbitConfig>(Newtonsoft.Json.JsonConvert.SerializeObject(result));
                Log.Logger = new LoggerConfiguration()
                    .Enrich.WithClientIp()
                    .Enrich.WithRequestHeader("User-Agent","UserAgent")
                    .Enrich.WithProperty("AppName", _serilogConfig.ClientName)
                    .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Error)
                    .WriteTo.RabbitMQ((client, Skin) =>
                    {
                        client.Username = _serilogConfig.UserName;
                        client.Password = _serilogConfig.Password;
                        client.Exchange = _serilogConfig.Exchange;
                        client.ExchangeType = _serilogConfig.ExchangeType;
                        client.Port = _serilogConfig.Port;
                        client.RouteKey = _serilogConfig.RouteKey;
                        client.VHost = _serilogConfig.VirtualHost;
                        client.DeliveryMode = (_serilogConfig.Durable ? RabbitMQDeliveryMode.Durable : RabbitMQDeliveryMode.NonDurable);
                        client.Hostnames.Add(_serilogConfig.HostName);
                        Skin.RestrictedToMinimumLevel = (LogEventLevel)_serilogConfig.LogLevel;
                        Skin.TextFormatter = new JsonFormatter();
                    })
                    .Enrich.FromLogContext()
                    .CreateLogger();
                //需要本地记录的化,在上面添加一句 .ReadFrom.Configuration(Configuration)
            }
            else
            {
                Log.Logger = new LoggerConfiguration()
                    .Enrich.WithClientIp()
                    .ReadFrom.Configuration(Configuration)
                    .Enrich.FromLogContext()
                    .CreateLogger();
            }

appsettings.json

  "SerilogRabbitConfig": {
    "HostName": "172.20.20.20",
    "Port": 8072,
    "VirtualHost": "/",
    "UserName": "loger",
    "Password": "123456",
    "Exchange": "serilog",
    "ExchangeType": "topic", //direct直连模式 topic通配符模式
    "QueueName": "serilog",
    "LogLevel": 0,
    "Durable": true,
    "WatchKey": "log.*", //监听的时候使用*匹配一个词语 #匹配多个词语
    "RouteKey": "log.serilog", //*匹配一个词语 #匹配多个词语 他们之间用.隔开 后续可以基于这个拆分消费者
    "ClientName": "SmartTool",//最大字符16不支持_符号,表示服务名称,用于追踪代码所属应用
    "MaxChannelCount": 2
  },

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

待完成事宜

1.查询小时报表的时候,可能缺失上一个小时和当前小时的数据,需要查询的时候手动从handler中调取,然后并入查询结果中

2.关于一些数据的回收问题,比如Information的数据,是保留3个月还是6个月,过期的数据的删除问题,不然一直增大!

3.关于日志消息json模块的查询问题,这个我看了下由于属性没几个,没做这一块的查询支持,其他的是支持的

4.关于应用appname,系统里面是按照appname拆分的,也就是说日志是按照appname分割的,那么就有登陆账号允许查看哪些应用的日志信息的问题这个没做过滤

5.目前写入了webhook的日志推送,比如某一个应用发生了error,则按照设定的webhook推送一条消息!这个消息的频率目前没有做限定,是否要做限定,限定的频率是多少等这里没有实现
MIT License Copyright (c) 2024 PasteCode Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

ELK如果对于你来说太大,那么可以试试这个PasteLoggerBoard,一款使用.netcore编写的日志收集系统,快速集成于现有系统,采用Postgresql+redis+rabbitmq的方式,收集程序的日志并显示报表,状态通知(推送webhook)等! 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C#
1
https://gitee.com/pastecode/paste-logger-board.git
git@gitee.com:pastecode/paste-logger-board.git
pastecode
paste-logger-board
PasteLoggerBoard
master

搜索帮助