log4net:ERROR XmlConfigurator:

简介: 近期对原来的项目工程添加了一个test project对原工程进行nunit测试,运行msbuild后报如下错误:log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .

近期对原来的项目工程添加了一个test project对原工程进行nunit测试,运行msbuild后报如下错误:

log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />

 

经查找发现原工程NHibernate中使用了

        private void InitSessionFactory()
        {
            Configuration cfg = new Configuration();
            cfg.Configure();
            log4net.Config.XmlConfigurator.Configure();
            sessionFactory = cfg.BuildSessionFactory();
        }

在test project的app.config中并未加入与原工程web.config的log4net配置,经加入

  <configSections>
    <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
  </configSections>

  <log4net>
    <appender name="rollingFile" type="log4net.Appender.RollingFileAppender,log4net">
      <param name="File" value="c:\LogData\log.txt"/>
      <param name="AppendToFile" value="false"/>
      <param name="RollingStyle" value="Date"/>
      <param name="DatePattern" value="yyyy.MM.dd"/>
      <param name="StaticLogFileName" value="true"/>
      <layout type="log4net.Layout.PatternLayout,log4net">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n"/>
      </layout>
    </appender>
    <root>
      <priority value="DEBUG"/>
      <appender-ref ref="rollingFile"/>
    </root>
  </log4net>

后问题解决


目录
相关文章
|
7月前
|
SQL 监控 关系型数据库
|
网络安全
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://xxxx.svc.cluster.local:8080/xxxx": Connection reset; nested exception is java.net.SocketException: Connection reset 什么原因导致得
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "xxxx.svc.cluster.local:8080/xxxx ": Connection reset; nested exception is java.net.SocketException: Connection reset 什么原因导致得
2724 0
|
5月前
|
应用服务中间件 nginx
nginx error日志 client intended to send too large body: 1434541 bytes 如何处理?
【8月更文挑战第27天】nginx error日志 client intended to send too large body: 1434541 bytes 如何处理?
441 6
|
6月前
|
数据库连接
系统日志使用问题之如何区分WARN和ERROR级别的日志
系统日志使用问题之如何区分WARN和ERROR级别的日志
|
6月前
|
架构师 存储
软件交付问题之在设计领域模型和状态机时,模型和状态机,如何解决
软件交付问题之在设计领域模型和状态机时,模型和状态机,如何解决
|
5月前
|
Oracle 关系型数据库
Navicat 连接Oracle ORA-28547: connection to server failed, probable Oracle Net admin error
Navicat 连接Oracle ORA-28547: connection to server failed, probable Oracle Net admin error
138 0
|
7月前
|
SQL 监控 关系型数据库
|
8月前
|
Android开发
双击eclipse提示an error has occurred See the log file E:\javatool\eclipse-mars-2\configuration\156991769
双击eclipse提示an error has occurred See the log file E:\javatool\eclipse-mars-2\configuration\156991769
90 1
|
Java 容器
RestTemplate报错I/O error on POST request for "http://crmjob.xxx.xxx.com/removeJob": Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out问题处理
讲述RestTemplate报错I/O error on POST request for "http://crmjob.xxx.xxx.com/removeJob": Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out处理方案
|
8月前
|
Java 程序员
SpringBoot集成log4j2出现Logback configuration error detected: current ElementPath is
SpringBoot集成log4j2出现Logback configuration error detected: current ElementPath is
120 0