Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Catching stdout/stderr of all programs to a logfile.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Skotlex
Apprentice
Apprentice


Joined: 13 Mar 2004
Posts: 293

PostPosted: Thu Mar 18, 2004 3:36 am    Post subject: Catching stdout/stderr of all programs to a logfile. Reply with quote

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:
Code:

STDOUTLOG=~/.stdoutLog
STDERRLOG=~/.stderrLog
xscreensaver &
gaim 1>$STDOUTLOG 2>$STDERRLOG &
xmms 1>$STDOUTLOG 2>$STDERRLOG &
gkrellm2 -w 1>>$STDOUTLOG 2>>$STDERRLOG &
~/.logStart $STDOUTLOG $STDERRLOG &
fluxbox 1>>$STDOUTLOG 2>>$STDERRLOG
rm $STDOUTLOG
rm $STDERRLOG


The so called .logStart is a small bash script that opens two terminals to show the contents of the local log files:

Code:

#!/bin/sh
#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
logFont=""-misc-fixed-bold-r-normal-*-*-120-*-*-c-*-iso8859-2""
# Sleep for a while so that the windows manager can handle the window.
sleep 5
(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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum