On Tue, 20 Apr 2010, p...@aers.ca wrote:

> Everything works,  because the utf8 flag is set everything is fine.
> However, as soon as we start spawning threads...

Works for me also, only thing I changed was to add

     use utf8;

at the beginning as you're writing code in UTF8. Without it, I end up
with doubly-encoded characters in the log file (no warning, though).

Tested with perl-5.10.0 and perl-5.10.1.

-- Mike

Mike Schilli
m...@perlmeister.com

>
>
>
> use threads;
>
> use threads::shared;
>
> use Log::Log4perl qw(get_logger);
>
> Log::Log4perl->init_and_watch("log.conf", 60);
>
>
>
> my $char = "\x{30DE}\x{30A4}\x{30AF}";
>
>
>
> #my $a = threads->create(\&foo, 'Somecategory');
>
> #$a->join();
>
>
>
> foo('Somecategory');
>
>
>
> sub foo {
>
>        my $cat = shift;
>
>        my $log = get_logger($cat);
>
>
>
>        $log->info("character [$char]");
>
> }
>
>
>
> I get "Thread 1 terminated abnormally: Wide character in syswrite at
> /usr/lib/perl5/site_perl/5.8.8/Log/Log4perl/Appender/File.pm line 242."
>
>
>
> This seems to be a case where the file handle is losing the utf8
> property, and so it must be set again on the handle.  I'm not sure why
> exactly that happens and am still investigating but this seems to fix
> it:
>
>
>
> Adding to Log4perl/Appender/File.pm on line 242 above the syswrite:
>
>
>
> If (defined $self->{utf8}) {
>
>        binmode($fh, ":utf8");
>
> }
>
>
>
> Note that I have done testing on other file handles and this appears to
> affect everything.  Possibly I am doing something wrong and need to make
> Log4Perl more aware of threads?  The get_logger calls within the
> subroutine are there to simulate the usage of my program, and are
> possibly not the ideal use?
>
>
>
> Please let me know, great tool otherwise!
>
>
>
> -Pat
>
>
>
>
>
>

------------------------------------------------------------------------------
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to