Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use logdashboard to view visual logs

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "how to use logdashboard to view visual logs". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Logdashboard

The log panel is an open source project I wrote in Github, which aims to make viewing logs easy and fast. Online preview

Now there are log retrieval, trend chart, exception stack quick view, log details and so on.

Logdashboard supports a custom logging model to record more custom properties.

There are two kinds of log sources supported by logdashboard. It is recommended to use file sources when developing and database sources when deploying production environments.

File source

Database source

Support for page authorization and custom authentication filters at deployment time

For more information, please see the official website.

Getting started

Make sure DotNetCore SDK is installed on the machine, open PowerShell and run the following command, and we will create an empty AspNetCore project

Dotnet new empty installs the Nlog logging component

We need to do some other preparatory work when we open the project using VSCode or VisualStudio. Nlog is selected for logging component.

Install-Package NLog.Web.AspNetCore

Open Program.cs to add Nlog middleware to the CreateWebHostBuilder method, and copy the following code to override the CreateWebHostBuilder method

Public static IWebHost CreateWebHostBuilder (string [] args) = > WebHost.CreateDefaultBuilder (args) .UseStartup () .ConfigureLogging (logging = > {logging.ClearProviders (); logging.SetMinimumLevel (Microsoft.Extensions.Logging.LogLevel.Information);}) .UseNLog () .build ()

Add a Nlog.config to the project and right-click the file to copy to the output directory (always copy). Here is the full contents of Nlog.config

Configuration files need delimiters to be parsed by NLogDashboard. The default is | | and | end. Of course, these can be customized. See LogDashboard configuration.

Install LogDashboard

When the preparation has been completed, LogDashboard is installed

Install-Package LogDashboard

Open Startup.cs. We need to do two things.

Configure the service in the ConfigureServices method

Public void ConfigureServices (IServiceCollection services) {services.AddLogDashboard ();}

For more configuration, see LogDashboard configuration

Configure middleware in the Configure method

Public void Configure (IApplicationBuilder app, IHostingEnvironment env) {if (env.IsDevelopment ()) {app.UseDeveloperExceptionPage ();} app.UseLogDashboard (); app.Run (async (context) = > {await context.Response.WriteAsync ("Hello World!");});}

When you're done, run the project and navigate to / logdashboard in the browser. Then you can see the log panel.

Need to pay attention to when releasing!

Open the .csproj project file and add the following line, for reasons, see https://github.com/aspnet/Mvc/issues/6021

This is the end of false's "how to use logdashboard to view visual logs". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report