Re: [log4perl-devel] Can the DBIAppender Work in Multithread?
On Thu, 14 Apr 2011, Nan Cui wrote: When my code tried to create new threads, the logger in the sub-thread body threw out exception like this: thread failed to start: DBD::Oracle::db prepare failed: handle 2 is owned by thread 83e0008 not current thread 8973c18 (handles can't be shared between threads and your driver may need a CLONE method added) at Hi Nan, That might be a limitation in the Oracle driver. I'm not using Oracle personally, but I've gotten feedback on the DBI driver being piece of work, mainly due to the proprietary nature of the Oracle client interface. Anyway, if the driver doesn't allow sharing DB handles between Perl threads, you should be able to work around the problem by explicitly obtaining a new DB handle every time you create a new thread. For this, you need to call the _init() method of Log4perl's DBI appender, which you can do after retrieving the appender by name. Something like Log::Log4perl-appender_by_name( DBAppndr )-_init(); in your consume() function should do the trick. -- Mike Mike Schilli m...@perlmeister.com -- Fulfilling the Lean Software Promise Lean software platforms are now widely adopted and the benefits have been demonstrated beyond question. Learn why your peers are replacing JEE containers with lightweight application servers - and what you can gain from the move. http://p.sf.net/sfu/vmware-sfemails ___ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel
[log4perl-devel] Can the DBIAppender Work in Multithread?
Hi Gurus, I'm trying to get help from you as I'm facing a problem while trying to use the DBIAppender in multithreading code. When my code tried to create new threads, the logger in the sub-thread body threw out exception like this: thread failed to start: DBD::Oracle::db prepare failed: handle 2 is owned by thread 83e0008 not current thread 8973c18 (handles can't be shared between threads and your driver may need a CLONE method added) at /usr/cisco/packages/perl/perl-5.8.8/lib/site_perl/5.8.8/Log/Log4perl/Appender/DBI.pm line 88. I'm new to Perl. I heard of that DBI is thread-safe and this might be the root cause of this problem. But while accpting this, I still need a solution to make the logger work also in sub-threads. I tried to share the logger, but it came out with another error saying (in cleanup) Can't call method FIRSTKEY on an undefined value at . /Log/Log4perl/Logger.pm line 90 during global destruction.. And one fellow told me try to create new DBI connection while in new thread, but I have no idea of how to do it. Since you guys are the source, I'm turning to you. Can you guys show me a way to my destination? Would appreciate that. Thanks Regards, NC -- Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev___ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel
Re: [log4perl-devel] Can the DBIAppender Work in Multithread?
On Thu, 14 Apr 2011, Nan Cui wrote: I tried to share the logger, but it came out with another error saying (in cleanup) Can't call method FIRSTKEY on an undefined value at . /Log/Log4perl/Logger.pm line 90 during global destruction.. Can you post a snippet of code to reproduce this problem? -- Mike Mike Schilli m...@perlmeister.com -- Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev ___ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel