iBATIS.NET日志的处理方式是什么,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
iBATIS.Net中提供了方便的日志处理,可以输出sql语句等调试信息。
常用的有两种:
iBATIS.Net日志处理1、输出到控制台:
﹤configSections﹥ ﹤sectionGroup name="iBATIS"﹥ ﹤section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common" /﹥ ﹤/sectionGroup﹥ ﹤/configSections﹥
﹤iBATIS﹥ ﹤logging﹥ ﹤logFactoryAdapter type="IBatisNet.Common.Logging.Impl.TraceLoggerFA, IBatisNet.Common"﹥ ﹤arg key="showLogName" value="true" /﹥ ﹤arg key="showDataTime" value="true" /﹥ ﹤arg key="level" value="ALL" /﹥ ﹤arg key="dateTimeFormat" value="yyyy/MM/dd HH:mm:ss:SSS" /﹥ ﹤/logFactoryAdapter﹥ ﹤/logging﹥ ﹤/iBATIS﹥
iBATIS.Net日志处理2、利用log4net输出到文件:
﹤configSections﹥ ﹤sectionGroup name="iBATIS"﹥ ﹤section name="logging" type="IBatisNet.Common.Logging.ConfigurationSectionHandler, IBatisNet.Common" /﹥ ﹤/sectionGroup﹥ ﹤section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /﹥ ﹤/configSections﹥
﹤iBATIS﹥ ﹤logging﹥ ﹤logFactoryAdapter type="IBatisNet.Common.Logging.Impl.Log4NetLoggerFA, IBatisNet.Common.Logging.Log4Net"﹥ ﹤arg key="configType" value="inline" /﹥ ﹤/logFactoryAdapter﹥ ﹤/logging﹥ ﹤/iBATIS﹥
﹤log4net﹥ ﹤!-- Define some output appenders --﹥ ﹤appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"﹥ ﹤param name="File" value="f:\log.txt" /﹥ ﹤param name="AppendToFile" value="true" /﹥ ﹤param name="MaxSizeRollBackups" value="2" /﹥ ﹤param name="MaximumFileSize" value="100KB" /﹥ ﹤param name="RollingStyle" value="Size" /﹥ ﹤param name="StaticLogFileName" value="true" /﹥ ﹤layout type="log4net.Layout.PatternLayout"﹥ ﹤param name="Header" value="[Header]\r\n" /﹥ ﹤param name="Footer" value="[Footer]\r\n" /﹥ ﹤param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" /﹥ ﹤/layout﹥ ﹤/appender﹥ ﹤appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"﹥ ﹤layout type="log4net.Layout.PatternLayout"﹥ ﹤param name="ConversionPattern" value="%d [%t] %-5p %c [%x] <%X{auth}> - %m%n" /﹥ ﹤/layout﹥ ﹤/appender﹥ ﹤!-- Set root logger level to ERROR and its appenders --﹥ ﹤root﹥ ﹤level value="DEBUG" /﹥ ﹤appender-ref ref="RollingLogFileAppender" /﹥ ﹤appender-ref ref="ConsoleAppender" /﹥ ﹤/root﹥ ﹤!-- Print only messages of level DEBUG or above in the packages --﹥ ﹤logger name="IBatisNet.DataMapper.Configuration.Cache.CacheModel"﹥ ﹤level value="DEBUG" /﹥ ﹤/logger﹥ ﹤logger name="IBatisNet.DataMapper.Configuration.Statements.PreparedStatementFactory"﹥ ﹤level value="DEBUG" /﹥ ﹤/logger﹥ ﹤logger name="IBatisNet.DataMapper.LazyLoadList"﹥ ﹤level value="DEBUG" /﹥ ﹤/logger﹥ ﹤logger name="IBatisNet.DataAccess.DaoSession"﹥ ﹤level value="DEBUG" /﹥ ﹤/logger﹥ ﹤logger name="IBatisNet.DataMapper.SqlMapSession"﹥ ﹤level value="DEBUG" /﹥ ﹤/logger﹥ ﹤logger name="IBatisNet.Common.Transaction.TransactionScope"﹥ ﹤level value="DEBUG" /﹥ ﹤/logger﹥ ﹤logger name="IBatisNet.DataAccess.Configuration.DaoProxy"﹥ ﹤level value="DEBUG" /﹥ ﹤/logger﹥ ﹤/log4net﹥
看完上述内容,你们掌握iBATIS.NET日志的处理方式是什么的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。