I'm working on a very big project that was done by someone else. This code has many projects in it, and it's using NHibernate as ORM. The database is very busy, so I'm trying to diagnose the places where it's slow and try to diagnose the entire system flow.
One of the things I've done is add a log4net for NHibernate.SQL which outputs all running queries to a log file:
<logger name="NHibernate.SQL" additivity="false">
<level value="ALL" />
<appender-ref ref="NHibernateSQLAppender" />
</logger>
and this is the appender:
<appender name="NHibernateSQLAppender" type="log4net.Appender.RollingFileAppender">
<file value="NHibernateSQL.txt"></file>
<appendToFile value="true"></appendToFile>
<maximumFileSize value="15MB"></maximumFileSize>
<maxSizeRollBackups value="10"></maxSizeRollBackups>
<rollingStyle value="Size"></rollingStyle>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] [%line] %-5p %c [%x] <%X{auth}> - %m%n"></param>
</layout>
</appender>
In the log file I see a query that runs many times in a short period of time and I would like to find the code that runs it. I was able to find the hbm file by the table name, and the class that it's mapped to.
I searched for references to that class - but there are many.
So my basic question is how can I find which code runs that specific query? is that even possible?
Thanks