Nhibernate log sql queries with parameter values

445 views
Skip to first unread message

gsu...@outlook.com

unread,
Oct 14, 2013, 11:03:19 AM10/14/13
to nhu...@googlegroups.com
Hello
 
We would like to log nhibernate queries with parameter values but the "nhibernate" log doesn't do it, at least it just logs the queries with the parameters but not the value of the parameters, which makes the log useless. The "nhibernate.sql" logs the queries with the value of the parameters, which is what we want but we don't want to log the queries twice, once in the "nhibernate" and once in the "nhibernate.sql", the generated log files are already big, we don't want to make them bigger by logging double and useless information.
 
The only solution that we have found is to set the level of the "nhibernate" logger to "warn" and the level of the "nhibernate.sql" to "debug". Is that the only solution?
Is it possible to set level of the "nhibernate" logger to "info" and don't log the aqueries or to log the queries with the value of the parameters?

Oskar Berggren

unread,
Oct 14, 2013, 1:07:45 PM10/14/13
to nhu...@googlegroups.com
NHibernate typically use log4net for logging, so this question is really about what configuration abilities log4net provides. I recommend to study their documentation. There is various filtering features. And it's extensible so as the last resort you should be able to code something.

That being said, I wasn't aware that NH outputs SQL under the "NHibernate" logger. I get SQL as:
INFO  NHibernate.Loader.Loader
DEBUG NHibernate.SQL

If this is true for you too, perhaps you could modify the level of just the "NHibernate.Loader.Loader" logger.

/Oskar




2013/10/14 <gsu...@outlook.com>

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+u...@googlegroups.com.
To post to this group, send email to nhu...@googlegroups.com.
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages