Detailed installation steps for log4net in MVC

Source: Internet
Author: User
Tags log4net

First step, install Log4net and receive Log4net.xml file

After the installation is complete, locate Log4net.xml and place the file next to Global.asax in the root directory.

Go to the Log4net.xml file to find the <!--Debug only--and node
Change the name value of <logger name= "xxx" > Inside to start layer

The name of my startup layer here is mcsservice.

Find AssemblyInfo.cs files generally in the Properties folder below the boot layer
The last line in this file is added
[Assembly:xmlconfigurator (configfile = "Log4net.xml", Watch = True)]

Locate the Global.asax file and modify it inside.
Application_Start () Add a row above this method
private static readonly log4net. ILog log = Logmanager.getlogger (typeof (Mvcapplication));
The last line in this Application_Start () method joins
Xmlconfigurator.configureandwatch (New FileInfo (Server.MapPath ("Log4net.xml"));
Log. Debug ("log Started");

If there are some red wavy line error, right-click analysis can

Run your project and find the text file in the Logs folder in your boot layer's resource file to see your log.

Detailed installation steps for log4net in MVC

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.