Log4net Preliminary use

Source: Internet
Author: User
Tags log4net

Since I know the log4net, it has been used, has no problem, recently because of the project changes, the part of the code is separated, and then I call Loghelper in the UI project, I found in the local test everything is OK, but after publishing to the server is not normal. No error, but there is no log record. This problem has been tangled for hours, what permissions issues Ah, the version of the problem has been tried or not

It suddenly occurred to me that one of the changes in the project was to put the common class of log4net into another project, and then the UI project made the DLL call, but in fact the beginning of the question was also suspected, but the total feeling log4net belong to the physical resources, As long as the UI project reference log4net.config should be able to, so has always been considered to be other problems-alas, in fact, is in the dead, always take for granted!

So, I have referenced the Log4net.config in the class library that called Log4net, and also added [Assembly:log4net] to the AssemblyInfo.cs of the corresponding class library. Config.xmlconfigurator (configfile = "Log4net.config", configfileextension = "config", Watch = true)] This sentence, test, ok!

Before I recorded it, it occurred to me that if I deleted the Log4net.config file in my UI project, would it be a problem, then after the deletion, the test, ok!

Haha, in fact, it has been found here, Log4net.config file, as long as it exists in the class library directly called Log4net can, but the UI project AssemblyInfo.cs is still the same to add that sentence, otherwise it will fail

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.