Stdout Redirect

Redirect System.out and System.err to a file or a pipe


Generated exe supports to redirect System.out and System.err to a file as a log file, or to redirect System.out and System.err to a pipe, which will be another program's input.

The stdout redirection can be enabled by a configure item in configuration file. By default, stdout redirection is not enabled, except that stderr of Service type application is enabled.

Redirect to a Pipe

To redirect to a pipe makes it possible to use the advantages of cronolog, which is a powerful tool to split the output into daily or monthly logs. Use a "|" and "command line" as stdout target to redirect to a pipe.

Configure Item 'stdout' and 'stderr'

In configuration file, stdout is to redirect System.out, stderr is to redirect Sytem.err.

See stdout, stderr page for details of stdout rediection configuration.

About Service Type

For Service type of application, System.err is a redirected to a disk file by default.

See Run as Service page for more information about Service type of application.



Files created but remain empty

I added the internal config :

forcecwd .
stdout system.out.log
stderr system.err.log
singleinstance true
jre_order b

Log files are correctly created, but remain empty, while System.out.prinltn are outputing data while running it from console.

Note: Exe is done as a GUI application.

What am I doing wrong? Any tip to have output sent to the log file?

There is a temporary way to do this

I'm so sorry, some other customer has told me this problem too recently. For Windows & GUI type, the System.out cannot be outputted. It's very strange and I didnot find the reason yet.

You can use this temporary solution:

System.setOut(new PrintStream(new FileOutputStream("out.log")));

I'm sorry for the inconvenience.

Thank you for your answer and

Thank you for your answer and the tip.

Apparently it happens on Win7 64bits, but not under XP.

If I find out more info, I'll keep you posted.

Add new comment