Monday, March 12, 2012

Colored log4net log files in Notepad++

Some time ago, I can’t tell exactly when, I discovered Notepad++ (NPP). NPP is a great light weight text editor with tons of cool features.
I’m also a big fun of log4Net since I discovered when I added the logging features to Genexus and GXserver. It is so easy to implement and helpful that I have used it in every project I worked ever since.
So in my daily basis I get to work with log4net log files a lot. I was doing so last Saturday when it hit me, “I need syntax coloring for this”.
So I looked up and found a great post from Jon Galloway that explains how you can create your own “User Defined Language” in NPP. To my surprise it was pretty simple since NPP has a dialog to do so, I thought I’d have to some xml editing. The dialog does that for you and what’s even better you can see the results of what you’re changing while you’re doing it. 
The result is (to me) pretty cool. It’s now a lot easier to find the ERROR or WARN lines.
I also added a couple of features that basically are a better way to focus on what’s important.
Numbers are in yellow, single quoted strings are in red, each keyword (INFO, DEBUG, ERROR, WARN, FATAL) has its own color, plus I also added “comments”. By using the good old // to comment a line or /* to comment a block */, you can help you and others to pay attention to what really matters, or at least what you think matters.
So, how do you get this?
Simple way: If you have never defined of modified a User defined Language, you can simply download the posted file and override your existent in %APPDATA%\Notepad++ (Make sure you backup your file first)
“Harder” way: if you have modified of added a user defined language, you probably know what to do but anyways, download the file (same from above) open it in your favorite text editor ;) and copy the UserLang tag with its content and copy it to your current userDefineLang.xml file.

**We moved to GitHub! Download the file from:

As usual, this is 100% “works on my machine”]

Read Full Post