Filter log4net to a single thread using Notepad++

Over the years I’ve Googled and Googled for a solution to this. Heck I even tried Bing! Finally time + an urgent need permitted figuring out a simple solution. To filter down to one thread using Notepad++:

  • Copy the angle brackets and thread number to clipboard. E.g. “[12]”
  • Menu -> TextFX Viz -> Hide Lines without (Clipboard) text
  • Press Ctrl-A (Select all text)
  • Menu -> TextFX Viz -> Delete Invisible Selection
  • Press Ctrl-A (Select all text)
  • Menu -> TextFX Edit -> Delete Blank Lines
  • That’s it! You are now viewing one logging from only one Thread

This works very quickly even with 70,000+ line 10MByte log files. IMO it avoids the need for xml log4net logging and Chainsaw (or similar).Simpler is always better.

Demo: Two threads counting to 100:

Copy the angle brackets and thread number to clipboard. E.g. “[12]”

Menu -> TextFX Viz -> Hide Lines without (Clipboard) text

Press Ctrl-A (Select all text)

Menu -> TextFX Viz -> Delete Invisible Selection

Press Ctrl-A (Select all text)

Menu -> TextFX Edit -> Delete Blank Lines

That’s it! You are now viewing one logging from only one Thread

About these ads

6 thoughts on “Filter log4net to a single thread using Notepad++

  1. Jorge Sierra

    It looks, nice, now I think log4j and log4net allows to log to an ODBC data source, I guess you can insert into a database and then use some kind of select to filter that data. I am in favor of logging everyhing on a development phase.

    Reply
    1. dotnetworkaholic Post author

      Jorge, the main issues with logging to a DB are performance and another point of failure. If connection to the database is lost where is that logged :) Also I’ve seen simple systems virtually crippled and the issue turning out to be log4net -> DB logging. Rolling files are reliable and work fast but bring other issues such as filtering by thread and being distributed across the farm. As normal it’s pros and cons, it depends what’s important to your project. Performance normally wins on my projects but I tend to work on larger systems. We have up to three million devices sending data to my current system (one of HP’s mission critical services) so it has to work fast and be fault tolerant. SQL Queries of log files would be great though… there are ways to do it if you configure log4net/log4j to log in xml format but in general support staff (and myself!) don’t like the xml files. Plain text is easy to bring up in Notepad++, now we’ve learned to filter our biggest problem is gone

      Reply
  2. Michael Earls

    Paul,

    I was rebuilding my computer the other day and when I tried to download and install Notepad++, I got a virus warning. I thought there might be some mistake, so I tried to download it again. This time, our firewall blocked it as a trojan.

    I hope it’s going to be fixed, because I rely on Notepad++ for a lot of things.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s