Log4net write DB2 cheat via OLE DB & ODBC

Source: Internet
Author: User
Tags db2 db2 odbc driver ibm db2 ibm db2 odbc driver ole log4net

In the project encountered the need to record the operation log requirements, because it is a plug-in system, so do not take into account the limitations of the company framework, direct two-tier architecture directly connected to the database, consider using log4net connection DB2. Please forgive me this non-soft trained it small white, has been known to have a log4net, but in the work of the company has its own framework record, has never had the opportunity to contact. This time, just the opportunity to try your skill.

Here is a brief introduction to this plug-in system. Very simple,. NET+DB2 configuration, two-tier architecture, the general picture has, need to cut into the rights control and log system. Work very smoothly carried out, the authority system is trivial, log aspects log4net take to use, big deal Baidu a bit. Reference Baidu came out of the ODBC configuration of MySQL copy copy there, this can be good, a run, dumbfounded, not error, also did not write their own built the table, headache.

In the spirit of the study has always been, and then directly Baidu Log4net+db2+odbc and so on a variety of key words of the permutation, helpless, Baidu Log4net+db2+odbc The key words are almost no, are SQL Server, Oracle and so on, crash, You don't have to log4net even DB2? The only one to find a related blog post, Bo owner also just said DB2 V9.7 to Log4net via ODBC support is not good, not even on: (, OK ~ ~ ~ ~ ~ ~!!!! (my result proves that he is wrong). Then small white Help CSDN forum-no Echo, want to StackOverflow ask foreigner, long time not on, Google's JS library was wall, ask no problem-no language.

So small white with a bad mood to boil down to tonight. On the small white side curse log4net How not even a database even an error, while debugging the breakpoint, found Configurationmessages a Tuo resume, above impressively written, "Can't find System.Data.dll" (roughly this meaning, The little white is not mapped here). A flash of light, a vision, the reference in the System.Data.dll copy locally set to True, run it, became!

Here, the small white will log4net through ODBC to OLE DB connection DB2 configuration is listed below:

Log4net via ODBC

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Configuration>3   <configsections>4     < Sectionname= "Log4net"type= "log4net." Config.log4netconfigurationsectionhandler, log4net "/>5   </configsections>6 7   <log4netDebug= "true">8     <Root>9       < Levelvalue= "INFO"></ Level>Ten       <!--file record Format - One       <!--<appender-ref ref= "Rollingfile"/> - A       <Appender-refref= "ADONETAPPENDER_DB2"/> -     </Root> -  the     <Appendername= "ADONETAPPENDER_DB2"type= "log4net." Appender.adonetappender,log4net "> -       <buffersizevalue= "1"/> -  -        <!--SQL data Source - +       <ConnectionTypevalue= "System.Data.Odbc.OdbcConnection, System.Data"/> -  +        <!--SQL connection String - A       <connectionStringvalue= "DRIVER={IBM DB2 ODBC Driver}; hostname=192.168.44.11; port=50001;database=xxx; uid=xxx; pwd=xxx; Protocol=tcpip; " /> at       <CommandTextvalue= "INSERT into xxx VALUES (', ' , ', ', ', ', ')"/> -  -       <parameter> -         <parameternamevalue= "@log_level" /> -         <DbTypevalue= "String" /> -         <sizevalue= " the" /> in         <Layouttype= "log4net." Layout.patternlayout "value= "%level" /> -       </parameter> to     </Appender> +   </log4net> - </Configuration>

Log4net via OLE DB

1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Configuration>3   <configsections>4     < Sectionname= "Log4net"type= "log4net." Config.log4netconfigurationsectionhandler, log4net "/>5   </configsections>6 7   <log4netDebug= "true">8     <Root>9       < Levelvalue= "INFO"></ Level>Ten       <!--file record Format - One       <!--<appender-ref ref= "Rollingfile"/> - A       <Appender-refref= "ADONETAPPENDER_DB2"/> -     </Root> -     <Appendername= "ADONETAPPENDER_DB2"type= "log4net." Appender.adonetappender,log4net "> the       <buffersizevalue= "1" /> -       <ConnectionTypevalue= "System.Data.OleDb.OleDbConnection, System.Data" /> -       <connectionStringvalue= "PROVIDER=IBMDADB2; hostname=192.168.44.11; port=50001; uid=xxxx; pwd=xxx;database=xxx; Protocol=tcpip; " /> -       <CommandTextvalue= "INSERT into xxx VALUES (', ' , ', ', ', ', ')" /> +       <parameter> -         <parameternamevalue= "@message" /> +         <DbTypevalue= "String" /> A         <sizevalue= "4000" /> at         <Layouttype= "log4net." Layout.patternlayout "> -           <Conversionpatternvalue= "%message" /> -         </Layout> -       </parameter> -     </Appender> -   </log4net> in </Configuration>

Finally, one more how to check the breakpoint view of the log4net error, you can find out from where to look at the wrong one later:

Log4net write DB2 cheat via OLE DB & ODBC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.