微服务分布式日志-ExceptionLess篇

Posted long88

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了微服务分布式日志-ExceptionLess篇相关的知识,希望对你有一定的参考价值。

一、Exceptionless 简介

Exceptionless 是一个开源的实时的日志收集框架,它可以应用在基于 ASP.NET,ASP.NET Core,Web Api,Web Forms,WPF,Console,MVC 等技术栈的应用程序中,并且提供了Rest接口可以应用在 javascript,Node.js 中。它将日志收集变得简单易用并且不需要了解太多的相关技术细节及配置。
在以前,我们做日志收集大多使用 Log4net,Nlog 等框架,在应用程序变得复杂并且集群的时候,可能传统的方式已经不是很好的适用了,因为收集各个日志并且分析他们将变得麻烦而且浪费时间。
现在Exceptionless团队给我们提供了一个更好的框架来做这件事情,我认为这是非常伟大并且有意义的,感谢他们。
就让我们一起来看看吧。

官网:http://exceptionless.com/

GitHub:https://github.com/exceptionless/Exceptionless

二、ExceptionLess使用方式

  *  可在https://be.exceptionless.io直接申请试用,试用版有限制,每天最多3000条错误日志,如需更多使只能购买付费。

 *  ExceptionLess开源的分布式日志框架,可通过github下载安装,搭建完全属于自己的分布式日志。

三、安装使用效果
* 首页
技术分享图片
* 异常明细页
技术分享图片

还有更多,如快速搜索、错误邮件通知等功能就在此列举......

四、App.config 文件配置


<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
    <section name="exceptionless" type="Exceptionless.ExceptionlessSection, Exceptionless" />
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
  </startup>
  <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <extensions>
      ? ? <add assembly="Exceptionless.NLog" />
    </extensions>
    ? <targets async="true">
      <!--默认连接官网exceptionLess start -->
      <!--<target xsi:type="Exceptionless" name="exceptionless" apiKey="h8C1yN1CfmvHH6wxzNW4JxBEc78N4BfBvJI1mayz">
        ? ? ?         <field name="host" layout="${machinename}" />
        ? ? ?         <field name="identity" layout="${identity}" />
        ? ? ?         <field name="windows-identity" layout="${windows-identity:userName=True:domain=False}" />
        ? ? ?         <field name="process" layout="${processname}" />
        </target>-->
      <!--默认连接官网exceptionLess end -->
        
      <!--本地服务器 start -->
      <target xsi:type="Exceptionless" name="exceptionless" apiKey="7BvRwz9RohyG1Bz98TFxKdJX75ZzOCHLQNLwmpqT" serverUrl="http://XX.XX.XX.XX:50000/">
        <field name="host" layout="${machinename}" />
        <field name="identity" layout="${identity}" />
        ? ? ?  <field name="windows-identity" layout="${windows-identity:userName=True:domain=False}" />
        ? ? ?  <field name="process" layout="${processname}" />
      </target>
      <!--本地服务器 end -->

      <!--正常写日志-->
      <target name="console" type="ColoredConsole" encoding="utf-8" layout="${longdate}|${level:uppercase=true}|${logger}|${message}" useDefaultRowHighlightingRules="true"/>
      <target name="file" type="File" encoding="utf-8" fileName="${basedir}/logs/Trade-${shortdate}.log" layout="${longdate}|${level:uppercase=true}|${logger}|${message}" />
    </targets>
    ? <rules>
      <!--exceptionless start 日志-->
      <logger name="*" minlevel="Trace" writeTo="exceptionless" />
      <logger name="*" minlevel="Info" writeTo="exceptionless" />
      <!--exceptionless end 日志-->
        
      <!--正常输出 start -->
      <logger name="*" minlevel="Debug" writeTo="console" />
      <logger name="*" minlevel="Warn" writeTo="file" />
      <!--正常输出 end -->
    </rules>
  </nlog>
</configuration>

五、源代码地址:
* 链接: https://pan.baidu.com/s/15rEzv-gwwa0znVscPQ2mlg 密码: ecm6

以上是关于微服务分布式日志-ExceptionLess篇的主要内容,如果未能解决你的问题,请参考以下文章

分布式微服务必须配个日志管理系统才优秀,Exceptionless走起~~~

如何在控制台应用程序中使用分布式日志Exceptionless

分布式日志框架之ExceptionLess:自行搭建帮助文档翻译

asp.Net Core免费开源分布式异常日志收集框架Exceptionless安装配置以及简单使用图文教程

.NetCore下 Exceptionless 分布式日志的个性化处理

分布式日志收集系统 - ExceptionLess的安装配置使用