DevOps Zone is brought to you in partnership with:

Dror Helper is an experienced software developer has written and designed software in various fields including video streaming, eCommerce, performance optimization and unit testing tools. He is passionate about programming best practices and all things software development, and has been a guest presenter at several user group meetings and ALT.NET events. Dror's blog can be found at http://blog.drorhelper.com where he writes about unit testing, agile methodologies, development tools, programming languages and anything else he finds interesting. Dror is a DZone MVB and is not an employee of DZone and has posted 57 posts at DZone. You can read more from them at their website. View Full User Profile

Tip: Using Notepad++ to Read Log Files

06.13.2013
| 11036 views |
  • submit to reddit

I had to read a log file containing a few hundred lines today at work.

My first instinct was to open it using my trusty Notepad++. While the file was not huge it was still difficult to traverse it and my eyes kept jumping between lines. Finding the  errors and warning was proving to be a hard task.

Since each line started with the severity of the message (trace/debug/info/warning/error) all I was missing was basic text highlighting – now where can I find such a tool :)

image

I’ve set out for work - the only question being – how hard would it be (spoiler: easy).

Step 1 – under Language choose Define your language

image

A new dialog will be opened. If you prefer you can dock it to the screen.

Choose Keywords tab

image

Define new keywords for Error, Warning  and any other severity you wish to highlight.

Choose the Styler button and set custom background (or foreground) for each severity.

image

And finally use Save as and name your new “language” – and a new language is born.

image

This is what the log looks like now – easy to read and spot the errors. I only wish I could have marked the whole line but at least now I can tell where the errors are.

image

Not too bad for less than one minute of work.

Published at DZone with permission of Dror Helper, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Aravind Yarram replied on Thu, 2013/06/13 - 8:51am

Followed this process but I doesn't see any difference. I think "Define you language" is broken in my version 6.3.3. What version are you using?


Dror Helper replied on Sat, 2013/06/15 - 1:14pm in response to: Aravind Yarram

Have you selected the new "language" from the languages menu?

Also make sure the works have the correct case as the syntax is case sensitive by defualt.

Bean Duke replied on Wed, 2013/06/19 - 10:41am

egrep -i "warning|error|critical"   log.txt anyone?

Jim Cheesman replied on Thu, 2013/06/20 - 5:25am in response to: Bean Duke

This doesn't always work: you lose the context, and the error message is often only understandable in the light of the preceding "info" level traces.

I usually use grep on long files in the following way:

1. grep -C 10 'my error text' log.txt 

In this step find the timestamp of the error, and a bit of context. Assume timestamp is format HH:MM:SS.sss

2. grep 'HH:MM' log.txt > much_smaller_log.txt

Note I've cut off the seconds to get the whole context. You've now got a much easier to handle file which only covers the minute you're interested in.

Another helpful practice is including the thread id on Java server logs, this is often directly related to a single web request. Work out what the thread id is (using step 1 above), then instead of grepping the time use the id in step 2.




Denis Tunovic replied on Sun, 2013/07/14 - 11:58am

If you're Windows user, try BareTail.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.