Redirect System.out and System.err to a file or a pipe
- System.out and System.err of Console type program will be outputted to Console Window or Terminal.
- System.out and System.err of Windows GUI type program will not be outputted.
- System.out of Service type program will not be outputted, System.err will be outputted to a disk file.
The configure items 'stdout' and 'stderr' are respectively used to redirect System.out and System.err to a file or a pipe. Error messages and Exceptions are outputted through System.err by default.
To a File
If the configure item 'stdout' or 'stderr' is followed by a file path, the redirect target is a file.
You can use a relative path or an absolute path. If the file path is a relative path, it is based on the "current working directory". For example:
forcecwd . stdout logs/system.out.log stderr logs/system.err.log
The first line is to make sure the "working directory" is the directory of generated exe.
To a Pipe
If the configure item 'stdout' or 'stderr' is followed by a '|' and a 'command line', the target is a pipe.
The command line should be executable from the "current working directory". It is strongly recommended to use 'cronolog' to split the output into daily or monthly logs.
For example, if your program is "/usr/folder/appdir/bin/program", the "cronolog" is at "/usr/folder/appdir/bin/cronolog", then:
forcecwd .. stdout |bin/cronolog logs/system.out.%Y%m%d.log stderr |bin/cronolog logs/system.err.%Y%m%d.log
The first line is to set the "working directory" to "/usr/folder/appdir/", from this "working directory", the "cronolog" is at "bin/cronolog", the file will be created in the directory "/usr/folder/appdir/logs/".
- cronolog.org - home page of cronolog