使用logdashboard进行可视化的日志追踪

本文源码在Github能够找到下载html

LogDashboard

若是你还不了解LogDashboard请看这里。 LogDashboard 1.1版本支持请求追踪,虽然目前版本尚未发布。不过这个功能能够先睹为快git

效果图github

<img src="https://img2018.cnblogs.com/blog/832799/201901/832799-20190117173526959-1881709032.gif" referrerpolicy="no-referrer">shell

下载项目

首先咱们能够在 https://github.com/liangshiw/LogDashboard/tree/master/samples/RequestTracking 里下载源码,而且使用VisualStudio打开项目,目录结构以下数据库

<img src="https://img2018.cnblogs.com/blog/832799/201901/832799-20190117173749277-394501522.jpg" referrerpolicy="no-referrer">ide

配置说明

咱们将 RequestTracking 设置为启动项目, 打开startup.cs文件能够看到LogDashboard服务与中间件已经配置成功.spa

在添加服务时咱们添加了自定义的LogModel RequestTraceLogModel 事实上RequestTraceLogModel是LogDashboard预构建的日志模型, 除此以外LogDashboard提供了接口IRequestTraceLogModel以便开发者自定义本身的追踪模型。日志

咱们把目光转到Config上面,这个示例使用了Nlog日志组件,Nlog提供了 ${aspnet-traceidentifier} 作为请求标识, log4net也一样能够实现code

<target xsi:type="file" name="File" fileName="${basedir}/logs/${shortdate}.log"
            layout="${longdate}||${level}||${logger}||${message}||${exception:format=ToString:innerFormat=ToString:maxInnerExceptionLevel=10:separator=\r\n} || ${aspnet-traceidentifier} ||end" />

在运行时咱们依次输出了如下日志orm

<img src="https://img2018.cnblogs.com/blog/832799/201901/832799-20190117172628099-1963841023.jpg" referrerpolicy="no-referrer">

启动项目

如今启动项目并导航到 /LogDashboard , 这时会看到日志面板的首页面,这时点击详情并找到请求追踪选项卡就能够达到文章开头动态图片演示的效果

<img src="https://img2018.cnblogs.com/blog/832799/201901/832799-20190117174118944-549362057.png" referrerpolicy="no-referrer">

数据库源

刚才看到的是文件源示例, https://github.com/liangshiw/LogDashboard/tree/master/samples/DatabaseSource 这个是数据库源的示例,一样支持请求追踪。操做方法与上面相似

More

欢迎入群交流

<img src="https://user-images.githubusercontent.com/16813853/51227366-df111580-198e-11e9-9e0c-f7b077e63fe7.png" referrerpolicy="no-referrer">

原文出处:https://www.cnblogs.com/LiangSW/p/10283574.html

相关文章
相关标签/搜索