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

SmartInspect with Web Services



I used SmartInspect with webServices c#.
All of my web services write on the same log file but I have found missing log messages.
I can not find logs for an entire random web service call.

I post you my configuration :

In GLOBAL.asax:

         void Application_Start(object sender, EventArgs e)
            // Code that runs on application startup
            // Enable Logging
            string path = System.AppDomain.CurrentDomain.BaseDirectory;
            SiAuto.Si.LoadConfiguration(path + "Logging.sic");

        void Application_End(object sender, EventArgs e)
            //  Code that runs on application shutdown

        void Application_Error(object sender, EventArgs e)
            // Code that runs when an unhandled error occurs
            Gurock.SmartInspect.Session session = SiAuto.Si[Session.SessionID];
            if (session != null)
                session.LogError("An unhandled MWServices exception occurred");

        void Session_Start(object sender, EventArgs e)
            // Code that runs when a new session is started
            Gurock.SmartInspect.Session session = SiAuto.Si.AddSession(Session.SessionID, true);
            session.Active = false;

        void Session_End(object sender, EventArgs e)
            // Code that runs when a session ends. 
            // Note: The Session_End event is raised only when the sessionstate mode
            // is set to InProc in the Web.config file. If session mode is set to StateServer 
            // or SQLServer, the event is not raised.

In each of WebService i have:

  • The method:
protected Gurock.SmartInspect.Session LogSession
                return SiAuto.Si[Session.SessionID];
  • And I start the log session with :
SiAuto.Si[Session.SessionID].Active = true;
            LogSession.Level = AppCore.loggingLevel;
            LogSession.EnterThread(Level.Message, logHeadBase + "- Method: 'methodname'");
            LogSession.EnterMethod(Level.Message, this, logHeadBase + "methodClass.methodName");
            LogSession.LogString(Level.Debug, logHeadBase + "username", yLogin);
            LogSession.LogMessage(logHeadBase + "Customer Authentication on MobankSystem");
  • My configuration file is :
appName = WebServices
connections = file(filename="C:\LOG_Files\MWS.sil")
defaultLevel = Debug
enabled = True
level = Debug

If I have configured SmartInspect correctly my questions are:

  • Can I have more details of how to write files smartInspect?
  • What frequency of writing log messages can endure SmartInspect?
  • If SmartInspect crashes I will lose the entire session log messages?

Thank You





Thanks for your posting. The missing log messages in your ASPX application are probably caused by the fact that a single log file can only be opened by a single (ASPX) process at the same time. When one of your requests runs in a different web server process, it may not be able to open the log file and silently discards the log messages (possible connection errors can be checked with the SiAuto.Si.Error event). With ASPX/web applications, we therefore usually recommend adding a process identifier to the log file so that each process gets its own log file.

  • General details and configuration options about writing log files are available in the online help of SmartInspect (press F1 in the SmartInspect Console, then go to Working with SmartInspect | Connections and Protocols).

  • SmartInspect’s file performance depends on the configuration options and the underlying I/O system. We have an article about SmartInspect’s performance which explains the properties of the individual log protocols:

  • By default, SmartInspect flushes each log message to disk. This makes sure that all messages are really written to disk in case of an application crash or unhandled exception. There are options to disable this behavior for improved logging performance (‘backlog’, ‘buffer’ etc., please see the online help for details).

Just let me know in case you have any further questions.

I hope this helps,