NHibernate log4net performance problem - how to disable?

I have profiled our ASP.NET application to try to reduce CPU usage and enjoy some strange behavior regarding NHibernate and log4net.

More than 50% of the time in our application is spent on the logLognet GetLogger and CreateRepository methods, which are called from ExecuteReader in NHibernate. The screenshot below is an analysis of the dotsrace dotsrace hotspot, where the arrows point from the calling method to the called method.

alt text

The screenshot below is just a list of the slowest features. As you can see, the NHybridDataReader constructor calls GetLogger, and it takes a lot of time.

alt text

, - , log4net NHibernate, .

web.config log4net, ? , , , .

, - ?

+3
3

( log4net NHibernate), Logging.cs NHibernate. (, 3,0 -, , 2.x), LoggerProvider GetNHibernateLoggerClass . , , . , GetNHibernateLoggerClass, , appsettings, "nhibernate-logger", "NHibernate.NoLoggingLoggerFactory, NHibernate". , log4net, DLL log4net ( , , NHibernate DLL. DLL log4net , , - , .

, , open source . , . , .NET ( ), , , .

BTW, , , NHibernate , , ( ILogger ILoggerFactory ).

+6

, , , , NHibernate, . log4net . , , , 3529 .

+5

NHibernate :

<logger name="NHibernate">
  <level value="ERROR" />
</logger>

I believe that it uses DEBUG by default and it writes a lot. I would not disable it completely, since you want to receive information about ERROR or FATAL events.

+1
source

Source: https://habr.com/ru/post/1767087/


All Articles