Log4net Unable to generate file or write log in release mode

Source: Internet
Author: User
Tags log4net

In debug mode all normal, but in release mode log4net not work, check a lot of information, finally solved. Do the following to check the changes.

1, check log4net write log file path is correct;

2, check the corresponding log file path has permission;

3, check the program log4net configuration to obtain the path;

The most common problem is the third step, which typically writes the following code in the AssemblyInfo.cs file

[Assembly:log4net. Config.xmlconfigurator (configfile = "Log4net.config", configfileextension = "config", Watch = True)]

However, this mode is not a problem in debug mode, but it is not good in release mode, you need to specify the location of the configuration file in the Global.asax file again, for example:

protected void Application_Start (object sender, EventArgs e)
{
Log4net. Config.XmlConfigurator.Configure (New FileInfo (Server.MapPath ("~") + @ "\log4net.config"));
}

Recompile the publication.

Log4net Unable to generate file or write log in release mode

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.