6

I use log4j to create rolling log files from my program. It writes to a log file until it reaches 256mb, and then it renames all the log files and creates a new log file and continues logging.

It is very useful for me to monitor these log files while my program runs, so I run "tail -f" on the log file to watch it in realtime.

The problem is occurs when the log rotation occurs, which does not happen at a predictable time. "Tail" is following the file with a particular handle, regardless of its name, so when the rotation occurs, tail is pointing to an old file that is no longer being logged to. If I stop and re-run the command, it will find the current file again.

How can I follow the most recent log file automatically? How can I follow a file with a given name, such that a log rotation will always show output from the newest file?

Thanks!

0

0

You must log in to answer this question.

Browse other questions tagged .