[Tutor] redirecting output to logfile and logrotate
Winfried Tilanus
winfried at tilanus.com
Fri Jul 22 10:14:02 CEST 2005
Hi,
I am installing a server-like python program that opens a logfile in
the following way:
# redirect output for logging to file
applog = open(config.log, 'a', 1)
sys.stdout = applog
sys.stderr = sys.stdout
Througout the program are lines like:
print '[', time.asctime(),']', message[:3]
The logfiles of the program can grow quite a big, so I decided to
include them in logrotate. That is where the problem started: everytime
the logfile gets rotated python loses track of it and stops logging.
The program is running on a linux server with python 2.2.
How can I make the logging (including stderr) 'logrotate-proof'?
thanks
&
Best wishes,
Winfried
--
http://www.xs4all.nl/~wtilanus/
More information about the Tutor
mailing list