记入最基本的用法 :
refer : http://www.cnblogs.com/aehyok/archive/2013/05/07/3066010.html
void Application_Start(object sender, EventArgs e){ log4net.Config.XmlConfigurator.Configure(); // Code that runs on application startup AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); }
public class HomeController : Controller{ private static readonly ILog log = LogManager.GetLogger("Loggering"); // GET: Home public ActionResult Index() { try { log.Info("log日志信息"); log.Debug("debug信息"); //log.Error("error信息"); //log.Warn("warn信息"); //Exception ex = new Exception("测试的异常信息"); //log.Fatal("fatal信息", ex); } catch (Exception ex) { throw; } return View(); } }