Keep an eye on your log

blog, testing

A great way to improve the testability of your software is to add logging! A log with all errors, warnings, faults, exceptions, dialog messages, or whatever is interesting for you in one file!

For most programmers it is relative easily to build in logging. When an application has a single class/procedure/library to handle errors, it is easy to build in logging. Depending on what you log it could become very easy for programmers to find the causes of crashes/bugs. If you are able log all user actions, it is just a matter of walking through the log file for the reproduction steps. Additionally, not all problems are visible in the GUI, sometimes a problem is only reported in a log file or some strange output is written to the log file.

However, when you have several servers up and running (database, application server, web server) it could produce a lot of logging. Testers are also humans.. so it could happen that you miss an important message in the log….

James Bach recognized this problem and wrote a small application in Perl to watch the log automatically. A great tool. However, the tool has some issues (for me):

  1. When you have several logs to watch, an application is started for every log file. As a result, the Windows task bar is polluted by extra programs on the taskbar;
  2. When you start the application, the old log is also watched. As a result, all already know issues are reported;
  3. Only explicit audio feedback, when the application is minimized there is no visual feedback;
I wrote a tool in AutoIT, with some improvements. The new tool has the same basic functionality as the tool of James Bach. However, the improvements are:
  1. The application is no longer visible in the task bar, it is visible in the notification area;
  2. When the application is started, it does not parse the existing log content;
  3. There is also visible feedback, by using a dialog;
  4. The option to open the log file directly from the notification icon;
Feel free to download this tool and use it or change it to your personally requirements. I’m still working on this tool and improving the tool. However, this version is ready to be used by you.
File Description
audio_logwatch.bat An example file to start multiple instances of logwatcher.exe to watch files.
error.wav Sample wav file, that gives you the raspy voice of James Bach during a bout of bronchitis.
license.txt The program is released under the GPL 2.0 license.
logwatcher.au3 The source code of the program.
logwatcher.exe A compiled version of the script, ready to be used.
readme.txt A file with some information about the tool and credits to James Bach.
watchlist.txt The file that contains the patterns to look for in the log files.

5 thoughts on "Keep an eye on your log"

  • Risko says:

    Hi! Can you make an option for logwatcher to create a file with the exceptions found? The pop-up is a bit annoying for me as I would like to be alerted only by the sound and later check the error messages. Otherwise thumbs up!

  • Ralph says:

    Thanks for your comment.

    I try to to minimize the features as much as possible. With every feature, a bug could be introduced ;).

    However, if you download yourself, it is relative easily to change the script.

    Open the file logwatcher.au3 and remove the line: MsgBox (0, “LogWatcher (Closes automatically in 15 seconds)”, “Search pattern: ” & $searchpattern & @CRLF & “File: ” & $log_filename & @CRLF & @CRLF & “Log: ” & $aRecords[$x],15). This line shows the dialog.

    In the current version (made it available this morning), the icon in the notification area has an option to open the log file directly. I think saving the errors to a separate log is not efficient. The error is already there on your disk… Of course feel free to add this feature to your personal version.

    To give you a quick start, look at the example of the procedure FileWrite in the help file of AutoIT, replace the line you have removed above, with a FileWrite statement. Just send me an email if you have any questions or ask for help on the AutoIT user forum.

  • Risko says:

    Thanks I'll give it a try! Another thing to note is that I am unable to hide the icons in the system tray in win XP. I have set the icons to always hide and they are hidden, but once I kill logwatcher.exe and restart them, the icons reappear as visible each time. Any comments on that? R.

  • Ralph says:

    No comments on that 😉 It is handled by AutoIT itself, try the autoit forum for more info on this.

  • Risko says:

    I was able to modify the source so that the program does exactly what I needed. Thanks again for the help : )

Leave a Reply

Your email address will not be published. Required fields are marked *