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

Log to file


#1

After adding

SiAuto.Si.Connections = "file(filename=c:\log.sil)"
SiAuto.Si.Enabled = True

as the first two lines in my aspx.vb code behind file

Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load

Things stop working. I don’t get a .sil log file in c:\ and removing

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

doesn’t bring back the logging to the console!


#2

Hello Morten,

the missing log file is probably the result of insufficient permissions of your ASP.NET application. Using log files in ASP.NET applications can be a bit tricky, because ASP.NET application normally have very limited rights.

You can find out if there is a permission problem by using the SmartInspect Error event (see the example below). By registering a handler to the Error event, you can see any errors that occurred while trying to open a log file. In order to get it working, the {MACHINE}\ASPNET user account needs write-permissions to the target directory of the log file (c:\ in your example).

Sub Si_Error(ByVal Sender As Object, ByVal Args As ErrorEventArgs)
   ' Output the exception 
   Response.Write(Args.Exception)
End Sub

Sub Application_Start(ByVal Sender As Object, ByVal e As EventArgs)
   AddHandler SiAuto.Si.Error, AddressOf Si_Error
   SiAuto.Si.Connections = "file(filename=c:\log.sil)"
   SiAuto.Si.Enabled = True
End Sub

By the way, as you can see in the example above, I suggest adding the SmartInspect initialization code to Application_Start instead of Page_Load. This way the log file is opened only once and not very time a page is loaded.

Hope that helps!


#3

Thanks Tobias
It was a case of the asp.net user not having rights to c:\log.sil