2009-07-10

Using Less to view Huge Log files

My job requires me to view large application log files (several hundred M bytes). My original favourite editor, Crimson editor has limitation because it loads the full file into the computer memory.

I try to find other alternatives and have tried LTF (Large Text File) Viewer but I find it has problems to search the patterns even though I do know it exists in the file.

Moreover, these editors still resort to load a large portion of the document into the computer and consumes many CPU resources.

Suddenly I think why I do not resort to the orginal text mode utitlies. A popular is less (wiki)

But if I can make the command prompt window bigger and customize the font, the user-experience will be much better.

I have written a batch file to use the "mode" and "color" command for this customization.

The full steps of installation are:

1. download the less in in here
2. Put the download into a directory (e.g. c:\bin\less429)
3. Create a batch file (e.g. less_big_win.cmd) which contains the following lines

@echo off
mode 160,40
color 0A
c:\bin\less429\less.exe %1

4. Associate a file type with the batch file



5. Open the log file using less


6. After opening, the less application is displayed in 160x40 new window:



7. Although my file has nearly 200M byte


you can see in the Task manager, it only consumes less than 1.5M bytes