Ever get stumped on a problem and just dont know where to look. Try the error logs! The Application's, OS's, App Server's, the FTP server's!
ALL logs are the unheard screams of your systems, the perverbial grimacing "
Ouch!". Instead of going to the code, or the GUI... When there is a problem go to the logs to see what ails your system.
Now, Unix pros know this inherently as do many Windows pros however there reside a large number of people whom are not aware of logs and there value!! So, having said that, I hope this enlightens that group and awakens those whom forgot!!
The tool of might for log monitoring is the
Tail.
Tail is found in Unix natively and in Windows you have to improvise. We'll discuss this later, for now the importance of how to use tail is our target.
Tail is a very simple concept and tool to use.
Tail is invoked by giving a file name (text file) and it will display the end of the file.. Simple enough! But the power of this simple utility povides you with the raw knowledge of the pain. That knowledge gets you closer to the cause!! End result, quicker solution and then, of course, hero status
:-)!
Let's pick Tomcat as an application with a problem. The first thing you can do is slap a
Tail command on the catalina.log.
Windows: tail c:/home/tomcat/logs/catalina.log
UNIX: tail /home/tomcat/logs/catilina.log
The result is
Tail will print out the last 10 lines (by default) displaying the most recent log messages, if any. The number of lines is a simple parameter and you can select how many lines to read from the end of the file by a command line parameter. The command line switch is
-n followed by a number.
ie: tail -n 20 catalina.org This would display the last 20 lines of the catalina.org file.
This line usage is a one time shot and is very useful when inspecting the file from time to time. However, there is a command line parameter
-f, that instructs
Tail not to stop displaying the contents when end-of-file is reached.
Tail will continue to wait for additional data to be appended to the input. Upon the file receiving this additional data,
Tail will continue to monitor the file and display the contents in
real-time. This provides a watch log (pun intended Woof Woof) functionality during testing or evaluation of a system.
The following example would keep catalina.log open to see real time activities.
Windows: tail -f c:/home/tomcat/logs/catalina.log
UNIX: tail -f /home/tomcat/logs/catilina.log
In Unix, Linux, MAC OS X, there is a capital 'F' option that is the same functionality of -f. However, it includes the ability to detect a rotation or the renaming of the file whilst continuing to display any additional updates. The inode number is monitored by tail to indicate a rename or a rotation to the file of focus. Upon a new inode number the current file is closed and the new file is reopened. This is very useful to maintain real-time monitoring of the log file of interest.
The format is simple :
Windows: tail -F c:/home/tomcat/logs/catalina.log
(CYGWIN IMPLEMENTATION)
UNIX: tail -F /home/tomcat/logs/catilina.log
That's all there is to it when monitoring rotating or renamed log files.
This tool is invaluable when looking into web server crashes, JVM dumps or operating system problems or any other logging activity. This tool works with text based files, I am afraid it won't be much help to binary logas, ie: found in Windows.
Nonetheless, logs in general are
OVER LOOKED in most operating systems by a large number of IT people.
Tail helps you with problem diagnosis and provides a solution to read these files fast. The next step is finding out how to identify logs for your operating system and how to handle the binary one's if they exist. That topic, we shall leave for another discussion.
Tail implementaitons for Windows can be found in Cygwin (
CW:Tail) or Sourceforge (
SF:Tail). Please note I am not try to push UNIX down anyone's throat so be cognizant of Cygwin's implementation as it is the WHOLE boat of Unix commands. The install is not substantial but it does require a Cygwin command line environment to work from.
Win32 Tail is a WINDOWS based solution and thusly, does not offer a command line version. However, it does provide an -f parameter to which you can monitor a log file. The
way cool thing here is Win32 Tail allows you to send an SMTP message upon updates to the log file. This could prove invaluable for a Severe Error Log. However, this could be painful for obvious reasons. Be mindful of how you implement this use. Also, just to be thourough, if you can send an email you can also send an email to SMS for phone alerts.
So, the bottom line, its all about the Error logs, and tail is your friend!
tags: sos tail troubleshooting tomcat error logs tomcat logs source debugging
links: digg this del.icio.us technorati reddit