Joined: 13 Mar 2004
|Posted: Thu Mar 18, 2004 3:36 am Post subject: Catching stdout/stderr of all programs to a logfile.
|Normally when people have problems with a program, the first thing one tries is to run it from a terminal to see if it prints out any errors.
There's people who like having a terminal displaying the tail of /var/log/messages to keep an eye on their system.
So why not combine both and also have a terminal displaying the output of all running programs?
I use fluxbox and aterm, but I suppose this would work for any other combination.
The excerpt that matters from my .xinit file:
gaim 1>$STDOUTLOG 2>$STDERRLOG &
xmms 1>$STDOUTLOG 2>$STDERRLOG &
gkrellm2 -w 1>>$STDOUTLOG 2>>$STDERRLOG &
~/.logStart $STDOUTLOG $STDERRLOG &
fluxbox 1>>$STDOUTLOG 2>>$STDERRLOG
The so called .logStart is a small bash script that opens two terminals to show the contents of the local log files:
#File that shows the contents of the local logs. The location of the stdout and stderr log files should have been passed on as $1 and $2
# Sleep for a while so that the windows manager can handle the window.
(aterm -geometry 90x10 -fn $logFont -title 'Standard Error Log' -name log -e tail -n 100 -f $2) &
(aterm -geometry 90x10 -fn $logFont -title 'Standard Output Log' -name log -e tail -n 100 -f $1) &
Change at will.. maybe you'll want to remove the stdout log as some programs just like printing information through it, but having the stderr output logged could prove useful to find out errors in programs otherwise you might never have noticed. One thing to note is that by just redirecting the output of the windows manager, all it's child processes get redirected as well, so every program I launch from within X gets logged ^.^
There might be other better ways to accomplish this, so bash at will.