"Z13 District", "Log4net write the appropriate log class" The third "end" "How to make it fit your own needs"

Source: Internet
Author: User
Tags log4net

First Article Open the door to Log4net's experience with a particularly simple example.

Second article with the theory, let's look at the meaning of those configuration files, and let's go back to the first written configuration file and the format of the output content.

in this article , " because of a lot of code and text narrative, it is easy to ignore some important information, so this article is basically source code-centric, simple in the blog to explain the key steps "

I will directly publish a source code "including most of the commonly used Apperder configuration", if you read the first two articles.

Basic can also read the source code content, "There will be a lot of notes in the source code."

GitHub Address: Https://github.com/tanshanli/Z13QU.Log4netDemo

"Project is written using vs2015, it is recommended to open with vs2012 and above"

There are github accounts that can be directly fork projects, and no GitHub account can be downloaded directly.

Project Analysis: NuGet packages are automatically restored after the project is run (it takes a little time)

1. Console log output (Basic understanding Log4net)

  

Three steps:

1. Writing the config file (log4netstudy.config)

2. Import Log4net.dll (directly in the VS Unget search, also available in the first article)

3. Add this sentence code to the namespace: [Assembly:log4net. Config.xmlconfigurator (configfile = "Config's absolute path or relative path", Watch = True)]

Then you can write code that "the comments for the code are all in Program.cs ".

2. Form programs (where most output logs are included)

If you look at the output of log4net on the console, you can basically understand the configuration file in config.

Next you need to directly use

"Z13 District", "Log4net write the appropriate log class" The third "end" "How to make it fit your own needs"

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.