ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles Bayon (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Closed: (IBATISNET-80) Store additional <statement> debug information in the MDC
Date Sun, 10 Jul 2005 16:00:12 GMT
     [ http://issues.apache.org/jira/browse/IBATISNET-80?page=all ]
     
Gilles Bayon closed IBATISNET-80:
---------------------------------

    Fix Version: DataMapper 1.3
     Resolution: Won't Fix

Ron has just added the statement id in the log.

> Store additional <statement> debug information in the MDC
> ---------------------------------------------------------
>
>          Key: IBATISNET-80
>          URL: http://issues.apache.org/jira/browse/IBATISNET-80
>      Project: iBatis for .NET
>         Type: Sub-task
>   Components: DataAccess
>     Reporter: Ron Grabowski
>     Assignee: Gilles Bayon
>     Priority: Trivial
>      Fix For: DataMapper 1.3

>
> I was trying to debug some strange entires in my log files today  (I added the ... part):
>  PreparedStatement : [SELECT ...]
>  Parameters: [@param0=[value,1]]
>  Types: [@param0=[Int32, System.Int32]]
>  PreparedStatement : [SELECT ...]
>  Parameters: [@param0=[value,1]]
>  Types: [@param0=[Int32, System.Int32]]
>  PreparedStatement : [SELECT ...]
>  Parameters: [@param0=[value,1]]
>  Types: [@param0=[Int32, System.Int32]]
>  PreparedStatement : [SELECT ...]
>  Parameters: [@param0=[value,1]]
> I realized that I had 100 <statement>s spread across 15 sql map files. It had been
a while since I last looked at this project so I had no clue were those statements were being
called from and why there were so many of them. It took me a while to finally track down what
was going on.  It would have been very helpful to see something like this in the log files:
>  Statement: [User.GetOne] PreparedStatement : [SELECT ...]
>  Statement: [User.GetOne] Parameters: [@param0=[value,1]]
>  Statement: [User.GetOne] Types: [@param0=[Int32, System.Int32]]
>  Statement: [User.GetOne] PreparedStatement : [SELECT ...]
>  Statement: [User.GetOne] Parameters: [@param0=[value,1]]
>  Statement: [User.GetOne] Types: [@param0=[Int32, System.Int32]]
>  Statement: [User.GetOne] PreparedStatement : [SELECT ...]
>  Statement: [User.GetOne] Parameters: [@param0=[value,1]]
>  Statement: [User.GetOne] Types: [@param0=[Int32, System.Int32]]
>  Statement: [User.GetOne] PreparedStatement : [SELECT ...]
>  Statement: [User.GetOne] Parameters: [@param0=[value,1]]
> I'm sure not everyone wants that much information; some of us want more even more! A
flexible solution may be to add this information to the log4net's MDC scope. The line that
creates the initial sql log:
>  if (_logger.IsDebugEnabled)
>  {
>   _logger.Debug("PreparedStatement : [" + command.CommandText + "]");
>  }
> could be changed to this:
>  if (_logger.IsDebugEnabled)
>  {
>   log4net.MDC.Set(LOG4NET_MDC_PREFIX + "StatementCacheModelName", statement.CacheModelName);
>   log4net.MDC.Set(LOG4NET_MDC_PREFIX + "StatementId", statement.Id);
>   log4net.MDC.Set(LOG4NET_MDC_PREFIX + "StatementResultMapId", statement.ResultMap.Id);
>   _logger.Debug("PreparedStatement : [" + command.CommandText + "]");
>  }
> In my case, I would have used this pattern in my Appender:
>  "%p %d (%c:%L) - Statement: %X{ibatisnet:StatementId} %m%n"
> Maybe this additional information could be used as a way to dispaly execution time statistics:
>  http://issues.apache.org/jira/browse/IBATIS-151
>  "%p %d (%c:%L) - Statement: %X{ibatisnet:StatementId} %X{ibatisnet:ExecutionTime} %m%n"

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message