Home
Name Modified Size InfoDownloads / Week
LogsGrep_0.0.3.zip 2011-10-25 5.1 kB
README.txt 2011-10-25 2.2 kB
Totals: 2 Items   7.3 kB 0
Grep utility designed specifically for logfiles containing multi-line log entries.

INSTALLATION
------------
1. Unpack the zip.
2. Add bin directory to your PATH.
3. In Unix-like systems, give execution permissions to the shell script (bin/logsgrep). 

Advanced java users can use "java -jar" method and extract needed info from shell scripts.

USAGE
-----
LogsGrep is taking its input from standard input and writing its output to standard output. There are tons of advanced tools to get input from files, URL-s and so on, so there is no point of including that logic into this utility.

Output is written using system's default file encoding. For advanced users, it can be changed using Java-s standard procedure for this: -Dfile.encoding=<encoding>.
Input encoding can be changed using optional encoding argument.

Most common usage is: logsgrep <searchPattern> <firstLogRowPattern> [inputEncoding]

Patterns are based on Java regular expressions: http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

Searchpattern is applied to the whole log entrie, which can have multiple lines (first row and stacktrace for example). So one can use \n as end of line marker in ones searchpatterns' or search from any line.

Lets say, our usual Log4J log row is something like:
2011-10-22 14:31:50,193 [192.168.40.45] DEBUG - web.MyWebController:132 - User 'onukristo' has requested a new ticket.

And lets say, we want to grep only log rows from requests made from my IP. Then you can write something like:
tail -f app.log | logsgrep 192.168.40.45 ^....-..-..

Or if you want to get all log entries which stack traces contain "NullPointerException", you can simply write
tail -f app.log | logsgrep NullPointerException ^....-..-..

And all log entries containing your search patterns will be displayed as a whole. No other log entries will be shown at all (which is not the case in common grep).

CHANGELOG
---------
0.0.3
.....
Unix execution script had DOS line-endings. Fixed to single LF line-endings. Also made sure, that DOS execution script has always right line-endings when packaged into distribution.
Added @echo off to DOS execution script.

Implemented compatibility with cygwin.
Source: README.txt, updated 2011-10-25