View Multiple Log Files in a Single Console - DevDummy

Latest

Guildes | Concepts | Techniques

Sunday, April 29, 2018

View Multiple Log Files in a Single Console

Multiple Log Files View in a Single Console




tail Multiple Log Files in to a Single Linux Console  

You may already know that it is possible to view a log file in Linux by tail command.

tail command allows to display existing log file content plus real time updating entries to the log.

Example :

tail -1000f /opt/apps/apache-tomcat-8.5/logs/application.log

However, If you want to keep on looking at multiple log files at once, what you can do is to have multiple tail command on several consoles to display the individual logs separately. 

May be you can use a console such as Terminator to divide the console area and display each log in there. but it gives you a shrinken area on each log.

It is fine but not much convenient if you have to look in to them at once in a single console in full size. 

There should be a better way !

What if all the log files you are monitoring are displayed as a single log file in a single console ?

Linux Magic

Just extend the above tail command adding the log file names separated by a space on each.

tail -f /opt/apps/apache-tomcat-8.5/logs/application.log /opt/apps/apache-tomcat-8.5/logs/catalina.log /opt/apps/apache-tomcat-8.5/logs/localhost.log 

Note : 
With multiple files, tail does not support displaying number of lines. It supports only the last 10 lines on the logs to display and the updating entries.

Usage

This is very helpful if you are working with a Tomcat Deployment, where you have to monitor multiple log files for errors at once.

FYI : Tomcat gives error messages in different log files as per the context of the error.

Example :
Application Logs- <application_name or configured name>.log
Container Logs- Catalina.log
System Logs- localhost.log

Here the logs are appended with log name separators making a differentiation between different log file entries.

==> /opt/apps/apache-tomcat-8.5/logs/catalina.log <==
27-Apr-2018 22:42:06.596 INFO [localhost-startStop-5] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/opt/apps/apache-tomcat-8.5/webapps/application.war] has finished in [34,927] ms

==> /opt/apps/apache-tomcat-8.5/logs/application.log <==
2018-04-28 23:11:48 INFO  ConnectionManager:12- Connecting now...



No comments:

Post a Comment