logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Juha Laiho <Juha.La...@iki.fi>
Subject Re: Logging messages directed to stdout
Date Sun, 18 Jan 2009 19:07:33 GMT
(this is getting off-topic for log4j, into just general Java
knowledge; apologies to the list for that)

With Java, an application is started by calling a known method from
a known class. When you're starting the program from an external
operating system, the class name is provided on the command line,
and the method name always is "main" (which only takes one argument,
an array of String objects, which contain the values of provided
command line arguments, if any).

Even when you cannot touch the original application, you can always
start the program with a class you write yourself. This class of
your own will set up the System.out and System.err streams to whatever
configuration you like, and after that initial set up just pass on
the command line arguments to the "real application".

It's no magic, and no violation of any rule; you're just using
public interfaces of the Java system, and of the program you cannot
change. There is a case, though, where this approach doesn't work:
it is when the application itself sets System.out/System.err to
values of its own and just discards the previous values - but
apparently you don't have this case, as you're seeing data on stdout.
-- 
..Juha


Jay wrote:
> Michael
>  
> I did refer to your two week old reply for a similar question.
>  
> I am able to write a java program (say program2) , which redirects stdout & stdin
to log file.
>  
> But, I am not sure, how do I redirect the stdout of already running program (JVM)  to
stdin of my new program (JVM). Should I use pipes ?  
>  
> If will be helpful, if you could provide complete syntax of the command.
>  
>  
> Please note that I donot have the option to modify the source of the already existing
java program (say program1). 
>  
> Thanks
>  
> --- On Fri, 1/16/09, Michael Erskine <michael.erskine@ketech.com> wrote:
> 
> From: Michael Erskine <michael.erskine@ketech.com>
> Subject: RE: Logging messages directed to stdout
> To: "Log4J Users List" <log4j-user@logging.apache.org>
> Date: Friday, January 16, 2009, 11:49 AM
> 
>> From: Jay [mailto:difficult_id@yahoo.com]
>> Subject: Logging messages directed to stdout
> 
>> 2) The new logging mechanism should not have any impact on the
>> performance of the application or the system
> 
> Not possible: unless you get a faster machine :p
> 
> I seem to answer this question every week - it isn't hard to redirect
> stdout and stderr and any programmer should able to do it. 
> 
> Regards,
> Michael Erskine.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> 
> 
>       


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message