MVC4 under Configuration log4net

Source: Internet
Author: User
Tags log4net

This article only say the main points, download and so on the Internet to search.

First step: Compiling Log4net.dll into the framework 4.0

Step two: Find the AssemblyInfo under the project's properties. Add at the bottom: [Assembly:log4net. Config.xmlconfigurator (Watch = True)].

Step three: Web. config

<configuration> <configSections> <section name="log4net"Type="System.Configuration.IgnoreSectionHandler"/> </configSections> <log4net> <appender name="Logfileappender"Type="log4net. Appender.rollingfileappender"> <file value="logs/"/> <appendtofile value="true"/> <rollingstyle value="Date"/> <datepattern value="Yyyy-mm-dd.txt"/> <staticlogfilename value="false"/> <layout type="log4net. Layout.patternlayout"> <conversionpattern value="%date Threadid:[%thread] Log level:%-5level class:%logger desp:%message%newline"/> </layout> </appender> <root> <appender-ref ref="Logfileappender"/> </root> </log4net></cconfiguration>

Fourth Step: Global.asax Applicatin_start method Add: ILog log = Logmanager.getlogger (Methodbase.getcurrentmethod (). DeclaringType);

has been completed, here is the call:

Logmanager.getlogger (Methodbase.getcurrentmethod (). DeclaringType). Error ("Logtest");

The calling method is not professional, just for demonstration purposes. Can be encapsulated for invocation.

MVC4 under Configuration log4net

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.