Asp.net core 2.0 Microsoft. Extensions. Logging text file log extension,

Source: Internet
Author: User

Asp.net core 2.0 Microsoft. Extensions. Logging text file log extension,

Microsoft officially provides native support for logs for asp.net core, which has the following implementation:

  • Console
  • Debug
  • EventLog
  • AzureAppServices
  • TraceSource
  • EventSource

By default, Comsole and Debug log output are enabled in the asp.net core Project template.

In actual production, it is not enough to output logs only on the console. We hope to use persistent carriers, such as text txt files.

Huanent. Logging. File is the implementation of Microsoft. Extensions. Logging text File logs. It is easy to use and detailed steps have been written on github.

Https://github.com/huanent/Huanent.Logging

 

Configuration instructions:

You can Install-Package Huanent. logging. file to install and expand, or search for Huanent in the nuget package browser. logging. after installing and configuring the plug-in, your asp.net core program will save the output logs to the logs folder under the program root directory, and divide the File name by date. install Huanent. logging. file2. in Program. add in cs File
Public static IWebHost BuildWebHost (string [] args) => WebHost. createdefabuilder Builder (args ). useStartup <Startup> () manually highlight -->. configureLogging (builder => builder. addFile ()). build ();
3. Configure the appsettings. json File and add a File node.
{"Logging": {"IncludeScopes": false, "Debug": {"LogLevel": {"Default": "Warning" }}, "Console ": {"LogLevel": {"Default": "Warning" }}, manual highlight --> "File": {manual highlight --> "LogLevel ": {manual highlight --> "Default": "Wanring" // you can modify the specific input level. You can also add a detailed category-based output manual highlight -- >} manual highlight --> }}}
Configuration complete

 

 

To reduce the impact of file read/write on performance, the plug-in maintains a message queue, asynchronously stores message logs, and has a low-configuration cpu (surface pro4 core M3) on the local machine) the number of writes per second in the test is more than 1000, which is sufficient for large projects.

 

 

 

 

 

  

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.