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

Using SmartInspect in Multiple Class Libraries


Is there a best practice recommendation when using SmartInspect in a .NET project containing a master forms project and many class library dll’s. I have currently added a seperate session within in each class library so I can distinguish by color where logging is occuring from and am not having any issues but once I move to a file logging scenario I’m not sure if there will be concurrency problems.


Hello Brent,

Your current implementation is also the solution we usually recommend: adding one or more sessions for each library (e.g., for each namespace) with different names and/or colors and using a single SmartInspect object that is used for writing the logging data.

As long as you are using the same SmartInspect parent object for all sessions, there will be no concurrency problems with log files. The SmartInspect class synchronizes the access to the log file so it’s safe to use from multiple sessions/libraries and/or threads.

To make sure that all sessions share the same parent SmartInspect object, it’s usually a good idea to use the SiAuto.Si object for adding sessions:

In the master project, you would then configure the SiAuto.Si object (connections, log level, enabled status etc.) and all sessions would share the same connections and options. Hope this helps.