Log4j mode is a major mode for viewing log files in Emacs. It can be used to view any text based log file, even though the name refers to a specific logging package. Log4j mode provides syntax highlighting, filtering, and source code browsing.
There are many applications that can be used to view log files, but using Log4j mode allows you to do it without leaving Emacs. It also provides good integration with the source code.
The major features of Log4j mode are described below. See screenshots for examples of how this looks in GNU Emacs.
Log4j mode uses log level keywords such as DEBUG and ERROR to syntax highlight log records. Different faces are used for different log levels. The user can customize the faces that are used for syntax highlighting.
Log4j mode can filter a log file buffer using keywords specified by the user, creating a new buffer that contains only matching log records. When the source buffer is auto reverted, the filter buffer will be updated too.
To filter a log file buffer, type C-c C-s, and enter the desired filter criteria - any number of keywords separated by spaces. Log records that contain any of the words in the include list, and none of the words in the exclude list, will be copied to the filter buffer. All other log records will be discarded. To stop filtering the log file buffer, just type C-c C-s again.
Source code browsing
Source code browsing is provided using jtags - an Emacs package for editing and browsing Java source code. It is possible to jump from a log file to a point in the source code where a certain log record was generated.
To show the source code for a Java identifier found in the log file, place the point in the identifier, and type C-c C-b. Log4j mode will parse the expression around point, and look up the Java identifier found using package jtags. If you are not using jtags, or if you are not developing in Java, you can still use the built-in tags lookup feature. Type M-. to run the find-tag command in the etags package.
The latest version of Log4j mode has been tested in GNU Emacs 21.3.1 and XEmacs 21.4.21 on Windows XP and Linux, and in GNU Emacs 22.0.990.1 on Windows XP.
Download the latest version of Log4j mode here, and start viewing your log files in color today. The package is available as a zip file, and as a gzipped tar file. The release notes can be found here. Installation notes are included within the Emacs Lisp file itself.
GNU Emacs users can also download and install Log4j mode from the Emacs Lisp Package Archive.
|© Johan Dykström 2008||Last modified: 2008-03-15 21:09:22|