zoukankan      html  css  js  c++  java
  • log4net内部调试开启

    最近用log4net写入日志到mysql数据库,死活写不进去,就想能不能看log4net的错误记录,在网上一找,还真有:开启log4net的内部调试,作个记录:

    <appSettings>
        <add key="log4net.Internal.Debug" value="true"/>
      </appSettings>
      <system.diagnostics>
        <trace autoflush="true">
          <listeners>
            <add
                name="textWriterTraceListener"
                type="System.Diagnostics.TextWriterTraceListener"
                initializeData="C:log4net.txt" />
          </listeners>
        </trace>
      </system.diagnostics>

    将这两个配置节放在<configuration>中

    <configuration>
      <configSections>
        <sectionGroup name="common">
          <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
        </sectionGroup>
      </configSections>
      <common>
        <logging>
          <!--2.此Adapter只输出到log4.net的配置文件所指定的地方-->
          <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1213">
            <!--FILE,FILE-WATCH,INLINE,EXTERNAL-->
            <arg key="configType" value="FILE" />
            <arg key="configFile" value="~/log4net.config" />
            <!-- 指定log4net的配置文件名称 -->
            <arg key="level" value="info" />
          </factoryAdapter>
        </logging>
      </common>
      <appSettings>
        <add key="log4net.Internal.Debug" value="true"/>
      </appSettings>
      <system.diagnostics>
        <trace autoflush="true">
          <listeners>
            <add
                name="textWriterTraceListener"
                type="System.Diagnostics.TextWriterTraceListener"
                initializeData="C:log4net.txt" />
          </listeners>
        </trace>
      </system.diagnostics>
      <connectionStrings>
        <add name="MySQL" connectionString="server=.;database=*****;Uid=****;Pwd=****;" />
      </connectionStrings>
        <system.web>
            <compilation debug="true" targetFramework="4.0" />
        </system.web>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.2.11.0" newVersion="1.2.11.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    
    </configuration>

    另log4net的mysql写法:

    <connectionType value="MySql.Data.MySqlClient.MySqlConnection, MySql.Data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>

    参照了此网页的评论:http://www.cnblogs.com/jimmyblog/archive/2008/08/18/1270665.html

  • 相关阅读:
    《团队名称》第八次团队作业:Alpha冲刺
    《代码敲不队》第八次团队作业:Alpha冲刺 第四天
    《代码敲不队》第八次团队作业:Alpha冲刺 第三天
    《代码敲不队》第八次团队作业:Alpha冲刺 第二天
    《代码敲不队》第八次团队作业:Alpha冲刺 第一天
    【Beta】Scrum meeting 3
    【Beta】Scrum meeting 2
    《队长说得队》第九次团队作业:Beta冲刺与验收准备
    【Beta】Scrum meeting 1
    《队长说得队》【Alpha】Scrum meeting 5
  • 原文地址:https://www.cnblogs.com/jancyxue/p/4579601.html
Copyright © 2011-2022 走看看