zoukankan      html  css  js  c++  java
  • Test log4net

     protected void Application_Start()
            {
                AreaRegistration.RegisterAllAreas();
                FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
                RouteConfig.RegisterRoutes(RouteTable.Routes);
                BundleConfig.RegisterBundles(BundleTable.Bundles);
                log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(Server.MapPath("~/log4net.config")));
            }
    public class LogController : Controller
        {
            //
            // GET: /Log/
            public ActionResult Index()
            {
                WriteLog(DateTime.Now.ToString());
                return View();
            }
    
            public static void WriteLog(string txt)
            {
    
                ILog log = LogManager.GetLogger("log4netlogger");
    
                log.Error(txt);
    
            }
    
        }

    PM> install-package log4net
    已安装“log4net 2.0.3”。
    正在将“log4net 2.0.3”添加到 WebApplication7。
    已成功将“log4net 2.0.3”添加到 WebApplication7。

    当前版本为  1.2.13.0

    CREATE TABLE [dbo].[Log] (
        [Id] [int] IDENTITY (1, 1) NOT NULL,
        [Date] [datetime] NOT NULL,
        [Thread] [varchar] (255) NOT NULL,
        [Level] [varchar] (50) NOT NULL,
        [Logger] [varchar] (255) NOT NULL,
        [Message] [varchar] (4000) NOT NULL,
        [Exception] [varchar] (2000) NULL
    )
     

  • 相关阅读:
    通过注册表获取计算机相关信息
    GetTickCount()函数
    SystemInfo获取计算机相关信息
    CriticalSection 临界区
    mysql慢查询问题
    mysql show processlist详解
    nginx及php版本号隐藏
    安装psutil模块报错&安装python-devel
    ubuntu ssh重启
    php-fpm配置优化
  • 原文地址:https://www.cnblogs.com/dotnetmvc/p/3657531.html
Copyright © 2011-2022 走看看