Dashboard > iBATIS DataMapper > Home > Frequently Asked Questions > How do I choose what sql statements appear in my log files
How do I choose what sql statements appear in my log files
Added by Ron Grabowski, last edited by Nathan Maves on Sep 15, 2005  (view change)
Labels: 
(None)


.NET DataMapper SVN Revision 209963 (DataMapper 1.2.1)

Note: This FAQ is based on .NET DataMapper code as of SVN Revision 209963 (DataMapper 1.2.1), a development revision of the .NET DataMapper. The log4net samples below have been tested with the 1.2.9 beta version of log4net.

The following log4net filter will only log sql statements originating from the User sqlMap namespace:

<filter type="log4net.Filter.StringMatchFilter">
    <regExToMatch value="^(?!Statement Id:)|Statement Id: \&#91;User\." />
    </filter>

The following log4net filter will only log sql statements whose ids begin with Insert, Update, or Delete. It will not log sql from Select or GetMany statements:

<filter type="log4net.Filter.StringMatchFilter">
    <regExToMatch value="^(?!Statement Id:)|Statement Id: \&#91;\w+?\.(?:Insert|Update|Delete)" />
    </filter>

Here is a complete FileAppender using one of the example filters:

<appender name="AspNetFileAppender" type="log4net.Appender.FileAppender">
    <file value="IBatisNet.txt" />
    <appendToFile value="false" />
    <layout type="log4net.Layout.PatternLayout" value="%5p %d (%c:%L) - %m%n" />
    <filter type="log4net.Filter.StringMatchFilter">
    <regExToMatch value="^(?!Statement Id:)|Statement Id: \&#91;\w+?\.(?:Update|Insert|Delete)" />
    </filter>
    <filter type="log4net.Filter.DenyAllFilter" />
    </appender>

Site running on a free Atlassian Confluence Open Source Project License granted to OSS. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.5 Build:#811 Jul 25, 2007) - Bug/feature request - Contact Administrators