Kevin, thank you for comprehensive reply.

> Well, the safest and most direct way would be to replace/augment all the
> prints to STDERR (like "warn" and "die") inside your script with
> log4perl logger calls.

I would prefer this solution, but how can I the redirect whole output
(or STDERR atleast) of the external command to die?
I am almost perl beginner, sorry, if this question is too easy.

>
> Or you could pipe the output of your script to another script that reads
> STDIN and implements logging like this:
>
>  command 2>&1 | perl -e 'use Log::Log4perl qw/:easy/; \
>  Log::Log4perl::easy_init($INFO);  \
>  while (<STDIN>){INFO $_}'

Can I do this in perl script directly?

   use Log::Log4perl qw/:easy/;
   Log::Log4perl::easy_init($INFO);
   $pid = open(STDIN, "ls nonsense 2>/dev/null |");
   while (<STDIN>){INFO $_};

Is there any way how to redirect STDOUT to INFO and STDERR to ERROR?
If both is not possible, STDERROR to ERROR is more important.

Thanks.
-John

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to