我是靠谱客的博主 贪玩电话,最近开发中收集的这篇文章主要介绍exceptionless 源码本地调式,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

一、准备环境:

.NET 5.0

Node.js

ES7

 

二、下载源码

#下载Exceptionless-7.0.9.tar.gz:https://github.com/exceptionless/Exceptionless/releases
#Exceptionless-7.0.9 用的是.net 5.0.100
本地安装.NET 5.0开发环境

修改Exceptionless.Web配置:

appsettings.Development.yml

---
ConnectionStrings:
  Elasticsearch: server=http://192.168.1.101:9200
  Cache: provider=redis;server="localhost,abortConnect=false"
#  Cache: provider=redis;
#  MessageBus: provider=redis;
#  Queue: provider=redis;
  Storage: provider=folder;path=.storage
#  LDAP: ''

# Base url for the ui used to build links in emails and other places.
BaseURL: 'http://localhost:9001/#!'

# Wether or not to run the jobs in process. Requires Redis to be configured when running jobs out of process.
RunJobsInProcess: true

Serilog:
  MinimumLevel:
    Default: Debug

Exceptionless.Job-appsettings.Development.yml

---
ConnectionStrings:
  Elasticsearch: server=http://192.168.1.101:9200
  Cache: provider=redis;server="localhost,abortConnect=false"
#  Cache: provider=redis;
#  MessageBus: provider=redis;
#  Queue: provider=redis;
  Storage: provider=folder;path=........Exceptionless.Webstorage

# Base url for the ui used to build links in emails and other places.
BaseURL: 'http://localhost:9001/#!'

Serilog:
  MinimumLevel:
    Default: Debug
    Override:
      Microsoft: Warning
      System: Warning
      Foundatio.Utility.ScheduledTimer: Warning
      Foundatio.Metrics: Warning

 启动:

#下载Exceptionless.UI-3.0.11.tar.gz:Exceptionless.UI https://github.com/exceptionless/Exceptionless.UI/releases
npm install
npx bower install
npx grunt serve

浏览器输入: http://ex-ui.localtest.me:5100 
注册用户:
名称:admin  
邮箱:admin@qq.com 
密码:admin123

运行效果: 

三、新建.netcore项目ExceptionLessDemo

  <ItemGroup>
    <PackageReference Include="Exceptionless.AspNetCore" Version="4.5.0" />
  </ItemGroup>

Startup.cs

using Exceptionless;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ExceptionLessDemo
{
    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.AddHttpContextAccessor();
            services.AddControllersWithViews();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
           
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }
            app.UseStaticFiles();

            ExceptionlessClient.Default.Configuration.ApiKey = "9ddtQSVFhMKYLYMUoBtgn5UzPql4Zy5sItO5RtBO";
            ExceptionlessClient.Default.Configuration.ServerUrl = "http://localhost:5000";
            app.UseExceptionless();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
    }
}
using Exceptionless;
using ExceptionLessDemo.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;

namespace ExceptionLessDemo.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        public HomeController(ILogger<HomeController> logger)
        {
            _logger = logger;
        }

        public IActionResult Index()
        {
            try
            {
                throw new DivideByZeroException();
            }
            catch (Exception ex)
            {
                ex.ToExceptionless().Submit();
            }
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}

 

最后

以上就是贪玩电话为你收集整理的exceptionless 源码本地调式的全部内容,希望文章能够帮你解决exceptionless 源码本地调式所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部