使用 UDP 协议发送日志
自定义好的查询 key 存储数据,尽量不要使用 服务端格式化日志再存储
Ubuntu 安装服务端
sudo apt-get update && sudo apt-get upgradesudo apt-get install apt-transport-https openjdk-8-jre-headless uuid-runtime pwgen
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5echo "deb [ arch=amd64,arm64 ] xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.listsudo apt-get updatesudo apt-get install -y mongodb-org
sudo systemctl daemon-reloadsudo systemctl enable mongod.servicesudo systemctl restart mongod.service
wget -qO - | sudo apt-key add -echo "deb stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.listsudo apt-get update && sudo apt-get install elasticsearchsudo systemctl daemon-reloadsudo systemctl enable elasticsearch.servicesudo systemctl restart elasticsearch.servicewget
sudo dpkg -i graylog-2.4-repository_latest.debsudo apt-get update && sudo apt-get install graylog-serversudo systemctl daemon-reloadsudo systemctl enable graylog-server.servicesudo systemctl start graylog-server.service
docker :
ASP.NET CORE 2 集成
nuget install Gelf.Extensions.Logging
public static IWebHost BuildWebHost(string[] args) { return WebHost.CreateDefaultBuilder(args) .UseStartup() .ConfigureLogging((context, builder) => { // Read GelfLoggerOptions from appsettings.json. builder.Services.Configure (context.Configuration.GetSection("Graylog")); // Optionally configure GelfLoggerOptions further. builder.Services.PostConfigure (options => options.AdditionalFields["machine_name"] = Environment.MachineName); // Read Logging settings from appsettings.json and add providers. builder.AddConfiguration(context.Configuration.GetSection("Logging")) .AddConsole() .AddDebug() .AddGelf(); }) .Build(); }
非 .net core 环境也可以使用 NLog 集成
REFER:
https://github.com/aspnet/Logginghttps://github.com/mattwcole/gelf-extensions-logginghttps://github.com/GokGokalp/NLog.Web.AspNetCore.Targets.Gelfhttps://blog.takipi.com/how-to-choose-the-right-log-management-tool/http://www.cnblogs.com/RainingNight/p/asp-net-core-logging-elasticsearch-kibana.htmlElasticsearch 疑难解惑http://www.cnblogs.com/clonen/p/8116386.html