Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

A few questions from a new user trialling SmartInspect



We have previously used the MSDN Enterprise Library for logging, but I’m looking at other solutions that allow log file rotation, etc. SmartInspect seems to do many of the things we need. However, I have a couple of questions:

  1. In writing to log files from a Windows Service, when I use the following (in VB.NET):

SiAuto.Si.Connections = “file(filename=.\log\log.sil)”

the directory ‘log’ is created under ‘c:\windows\system32’ (in XP) which is the root folder for the Services service, which I guess makes sense.

Is there a shortcut or any way to specify that I want the log file to be written to a ‘log’ folder under the folder where my Windows Service executable is installed? I can use the full path, but I would like to just specify as shown above if possible.

  1. When logging to the ‘log.sil’ file the SmartInspect console does not auto-update when the contents of the file changes - can this be enabled, or at least could you prompt the user that the contents of the file have changed since the file was opened (for example TextPad does this)?




Hello Chris,

Since you specify the path of the log file in a relative way, the log file is created under the current working directory of your service which seems to be ‘c:\windows\system32’ in your case. You can either change the working directory of your service (with Directory.SetCurrentDirectory) to your installation directory or include the installation directory in the log file path. To prevent hardcoding the installation directory, you can use the Assembly.GetExecutingAssembly().Location to get the installation location of your service at runtime. So, for example:

Dim Location As String = Assembly.GetExecutingAssembly().Location SiAuto.Si.Connections = String.Format("file(filename=""{0}\log.sil"")", _ Path.GetDirectoryName(Location)) SiAuto.Si.Enabled = True SiAuto.Main.LogMessage("Hello, World!")

There is currently no support for auto-reloading log files on changes. This feature is already on our feature request list, but I cannot promise if/when this feature will be available. In the meantime, there’s a shortcut (F5) to quickly reload the last log file.