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"