ExceptionLess是一款免费开源的分布式日志收集框架,DotNet的几乎所有类型的程序都可以支持,并且还提供了接口,可以很方便的在js中进行日志的推送。
参考:
http://www.cnblogs.com/uptothesky/p/5864863.html
http://www.cnblogs.com/savorboard/p/exceptionless.html
http://mp.weixin.qq.com/s?__biz=MzAwNTMxMzg1MA==&mid=2654067937&idx=1&sn=01e502d9ef5cf77817aa80db6903923d&scene=0#wechat_redirect
ExceptionLess的装分为两种:
解压elasticsearch如图:
java -version 如果报错的话有很多种可能,搜索一下会有解决方案,我的就是在C:\Windows\System32 目录下把java.exe改名成javaa.exe,再次cmd运行就成功了
在startup.cs中添加 引用:Startup全部代码:
using Exceptionless; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace WebApplication1 { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); } //public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) //{ // app.UseExceptionless(); // app.UseExceptionless("eUUE3Tf5EqGdpyBiD1I3BdIgT9cGxv7jSzmSUdLt"); // //app.UseExceptionless("15mT6MDBAxaVOQ4b8v6BxikgACwMr6Y3StSgs6B4"); // app.UseStaticFiles(); // app.UseMvc(); //} // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } ExceptionlessClient.Default.Configuration.ApiKey = "eUUE3Tf5EqGdpyBiD1I3BdIgTGxv7jSzmSUdLt"; ExceptionlessClient.Default.Configuration.ServerUrl = "http://localhost:50000"; app.UseMvc(); } } }
using Exceptionless; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; namespace WebApplication1.Controllers { [Route("api/[controller]")] public class ValuesController : Controller { // GET api/values [HttpGet] public IEnumerable<string> Get() { try { throw new Exception("测试日志演示"); } catch (Exception ex) { ex.ToExceptionless().Submit(); } try { throw new ApplicationException("控制器——ValuesController:" + Guid.NewGuid().ToString()); } catch (Exception ex) { ex.ToExceptionless().Submit(); } return new string[] { "value1", "value2" }; } // GET api/values/5 [HttpGet("{id}")] public string Get(int id) { return "value"; } // POST api/values [HttpPost] public void Post([FromBody]string value) { } // PUT api/values/5 [HttpPut("{id}")] public void Put(int id, [FromBody]string value) { } // DELETE api/values/5 [HttpDelete("{id}")] public void Delete(int id) { } } }
原文:https://www.cnblogs.com/aaaaq/p/9196123.html