Date Created: Fri 22-Jul-2011

Related Document Categories:

Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/





Viewing logs on the WebSphere Application Server file system

The best way to view the JVM logs is via the operating system. Linux provides command line options which allow the administrator to find and view log files very quickly. In Windows it is much harder to view and manage continuously growing log files. Scanning log files can be arduous if there are lots of logs with verbose log information, that is, if the logs are large in size. If Linux is chosen as the preferred OS, you can use Linux commands to search log files for keywords, phrases, error codes, and so on.

Linux provides two commands called grep and tail, which are the two most commonly used Linux commands when dealing with logs.

For Window users, it is possible to download Wintail.exe, a free Open Source equivalent of the Unix/Linux tail command.


Linux tail command

The tail command is very useful when you want to watch logs while the server is running and wish to watch the messages being written to the log as they happen in real time. To demonstrate using tail, we will watch an existing SystemOut.log using one SSH session as we start and stop the WAS instance in a separate SSH session.

1. Open an SSH session to your Linux box and navigate to <was_profile_root>/logs.
2. Then change directory to your server's log folder, that is, cd server01
3. Type the following command:
tail -f ./SystemOut.log

You should now have an SSH window opens looking something similar to the following screenshot:

Leave your existing SSH session open. Open a second SSH session to your Linux box and navigate to the <was_profile_root>/bin folder.

Type the following command to stop server01:

./stopServer.sh server01

You will see in the original SSH window the messages informing that the JVM is being stopped, as shown in the screenshots below.



In this new SSH session window we have used the ./stopServer.sh command to stop the server01 JVM. WAS reports that the server has stopped.

In the previous SSH session below, we used the tail command to watch the log. You can see that messages were being displayed as the server was stopping. The tail command keeps watching the log and displays the end of the file as the log file grows. The tail command keeps looking at the end of the file, hence the name tail.



The tail command will continue to watch the file until the command is canceled with Ctrl+C.

The tail command is one of the most common commands you will use during problem determination. It allows you to watch log files as the server is running so that you can identify error messages as they appear. You can research this further online to see more examples and command line options of the tail command, such as what we’ve demonstrated here.


Linux grep command

Another very useful command is the grep command. The grep command allows you to search files to see if they contain certain combinations of characters. The characters could be certain keywords, error messages, status messages, or any other combinations of text strings that you could be looking for in a single log file, or even a group of log files. To demonstrate the use of the grep command, we are going to look for the text string WebSphere Platform in all the log files in the JVM log directory.

Navigate to <was_profile_root>/logs/server01

Type the following command:

grep –i "WebSphere Platform" *

grep will do a case-insensitive search of all the files in the current directory scanning for the text, listing all files which contain the text sub-string WebSphere Platform as seen below.

The image above shows many successful finds. The grep command lists all lines of the files and the file name of every file in which it finds the search string. This is a very powerful tool and can be used in a number of different ways. As with the tail command, it is worth researching this further to learn and understand all variants and uses of the grep command as it is one of the most powerful command line tools in an administrator's arsenal, though more details than this are beyond the scope of this book..

Note: Windows users you can use the Windows find command, however it is not as powerful as the Linux grep command. There are however several Open Source ports for Windows versions of grep which can be readily found online.

Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/


Steve Robinson - IBM Champion 2013

About Me

Steve Robinson has been working in IT for over 20 years and has provided solutions for many leading brands around the world. Steve specialises in JEE, DevOps and Thought Leadership.

In January 2013, I was awarded the prestigous 'IBM Champion' accolade.


  • Linked In
  • Twitter
  • About Me
  • Contact Me

Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

Courses

  • WebSphere Courses

Articles

WebSphere Categories

Other Categories