Search code examples
nhibernatelog4netprofilerlog4net-configurationlog4net-appender

Error when trying to use <skipCapturingStackTraces> with NHProfAppender in NHibernate Profiler


Trying to follow https://www.hibernatingrhinos.com/products/nhprof/learn#Usage

I have the following log4net.config file:

<?xml version="1.0" encoding="utf-8" ?>
<log4net>
  <appender name="NHProfAppender"
      type="HibernatingRhinos.Profiler.Appender.NHibernate.NHProfAppender, 
      HibernatingRhinos.Profiler.Appender.NHibernateLog4Net">
    <sink value="tcp://127.0.0.1:22897" />
  </appender>
  <logger name="HibernatingRhinos.Profiler.Appender.NHibernate.NHProfAppender.Setup">
    <appender-ref ref="NHProfAppender"/>
    <skipCapturingStackTraces value="true"/>
  </logger>
</log4net>

I get the following Error:

log4net:ERROR XmlHierarchyConfigurator: Cannot find Property [skipCapturingStackTraces] to set object on [log4net.Repository.Hierarchy.DefaultLoggerFactory+LoggerImpl]

Can Someone explain why this error is received and how to fix it ?


Solution

  • SkipCapturingStackTraces is a property of the NHProfAppender, similar as the Sink property, so you have to configure it on the <appender> element.

    <appender name="NHProfAppender"
        type="HibernatingRhinos.Profiler.Appender.NHibernate.NHProfAppender, 
            HibernatingRhinos.Profiler.Appender.NHibernateLog4Net">
        <sink value="tcp://127.0.0.1:22897" />
        <skipCapturingStackTraces value="true" />
    </appender>