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. 
notepadlog4net
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: https://github.com/sebagomez/log4net-for-notepadpp

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

9 comments:

Enrique Almeida said...

Muy bueno.
Voy a probarlo.

Anonymous said...

Great! I was looking for this.
I had to change the colors though, since I prefer a white background.

Drew Douglas said...

@Anonymous, why not post your own, too?

@sebastian Well done, sir. Well done.

Drew Douglas said...

@sebastian Thanks for the file. It's great!

@Anonymous Why don't you post your edits so everyone can try your version, too?

Anonymous said...

:D :D :D

Anonymous said...

hi and thanks
what you are doing with word like don't and dosn;t that contains the char '?

thanks

Anonymous said...

what do you do if in the log you have the word "don't" or "did't" that contaons the char ' ?

thanks a lot.

Anonymous said...

what do you do if in the log you have the word "don't" or "did't" that contaons the char ' ?

thanks a lot.

Obat Herbal Gula Darah Tinggi Terbaik said...

Great article on our site. Keep up the good writing.