How to find and tail the Oracle alert log


When you take your first look at an Oracle database, one of the first questions is often "where's the alert log?". Grid Control can tell you, but its often not available in the environment.

I posted some bash and Perl scripts to find and tail the alert log on my blog some time back, and I'm surprised to see that post still getting lots of hits.

The technique used is to lookup background_dump_dest from v$parameter. But I only tested this on Oracle Database 10g.

Is there a better approach than this? And does anyone know if this still works in 11g?

10/8/2008 6:55:51 AM

Accepted Answer

Am sure it will work in 11g, that parameter has been around for a long time.

Seems like the correct way to find it to me.

If the background_dump_dest parameter isn't set, the alert.log will be put in $ORACLE_HOME/RDBMS/trace

10/5/2008 12:13:46 PM

Once you've got the log open, I would consider using File::Tail or File::Tail::App to display it as it's being written, rather than sleeping and reading. File::Tail::App is particularly clever, because it will detect the file being rotated and switch, and will remember where you were up to between invocations of your program.

I'd also consider locking your cache file before using it. The race condition may not bother you, but having multiple people try to start your program at once could result in nasty fights over who gets to write to the cache file.

However both of these are nit-picks. My brief glance over your code doesn't reveal any glaring mistakes.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow