Please remember this is a work in progress. Home » Classes

Classes

 

TIWExceptionLogger

 

The TIWExceptionLogger class is responsible for application exception logging. Whenever an exception occurs within an IntraWeb application, a detailed exception report will be generated. The report will be saved to a text file or to the Windows event log.
There is only one instance of this class per application, created by the application's ServerController. The ServerController exposes this class as a published property named ExceptionLogger.

Properties

Enabled: Boolean; (published)

Enables/disabled the exception log file creation.

FileName: string; (published)

Contains the prefix of the exception log file name. The file name will be appended with the symbol '@' plus a time stamp. The exception log file extension is always '.log'.
Default value is an empty string. Leave it empty to use the application name as the file name prefix.

FilePath: string; (published)

Contains the full path for the exception log folder.
Default value is an empty string. When empty, a folder named 'ErrorLog' will be created under your application path. This property is ignored when LogType <> ltFile.

LogType: TLogType; (published)

type TLogType = (ltFile, ltEventLog);
Indicates if the exception log will be created using text files or Windows Event Log.
Default value is ltFile.

When the ExceptionLogger is unable to save the text file (e.g. lack of permissions) it will use the Windows Event Log, automatically.

PurgeAfterDays: Integer; (published)

Exception log files older than 'PurgeAfterDays' days will be deleted during application shutdown. This property is ignored if the instance is disabled (Enabled = False).

ReportInfos: set of TReportInfo; (published)

type TReportInfo = (riAppInfo, riExceptionInfo, riIWAppInfo, riStackTrace);

Indicates which information will be logged to the exception log.

riAppInfo: Information about the application, such as:

  • Application name
  • Application version when available
  • Application startup time
  • Exception time
  • Application running time
  • Computer name
  • Compiler version

riExceptionInfo: Information about the exception object, such as:

  • Exception message
  • Exception class
  • Exception address

riIWAppInfo: Information about the IntraWeb session/application, such as:

  • IntrWeb version number
  • Application ContentPath
  • Application Path
  • List of forms of the current session, in the form: [Index in session's form list] Form Name (Form class name)
  • List of active forms of the current session, in the form: [Index in session's active form list] Form Name (Form class name)
  • Name of the browser associated with current session
  • User agent string of the browser associated with current session
  • Callback flag, indicating wheather the session is processing a callback (async) request

riStackTrace: The stack trace when the exception occurred, when available.

Note: Setting ExceptionLogger properties after ServerController creation is not thread safe and should be avoided. You should set all ExceptionLogger properties using ServerController's OnConfig event.

Methods

function LogException(Sender: TObject; E: Exception): Boolean; (public)

Called internally by IntraWeb to process the exception and save the log to file or event log. You probably do not need to call this method directly. This method does nothing when the instance is disabled (Enabled = False).

procedure RegisterIgnoreException(ExceptionClass: ExceptClass); (public)

This method registers exception classes to be ignored by the exception logger. When an exception of a certain class is raised and this class was previously registered, the ExceptionLogger will ignore it and no log will be generated.

Example:
  1. procedure TIWServerController.IWServerControllerBaseConfig(Sender: TObject);
  2. begin
  3. // tells the ExceptionLogger to ignore exceptions of class EConvertError
       ExceptionLogger.RegisterIgnoreException(EConvertError);
  4. end;
Note: RegisterIgnoreException is thread safe and can be safely called by sessions.

Example of a log file generated by TIWExceptionLogger

Exception message : ''A'' is not a valid integer value
Exception class : EConvertError
Exception address : 00424986
------------------------------------------------------------------------------------------------------------------------
Application Name : GuessSA.exe
Application Version: 1.0.0.1
Started at : 2013-04-01 11:00:46.820
Exception Time : 2013-04-01 11:15:57.685
Running for : 15 minutes 10 seconds
Computer Name : WebServer01
Compiler Version : 240
------------------------------------------------------------------------------------------------------------------------
IntraWeb Version : 14.0.7
Content Path : C:\Web\Guess\wwwroot\
Application Path : C:\Web\Guess\
Active Form : formMain (TformMain)
Active Form list : [1] formMain (TformMain)
Form list : [1] formMain (TformMain)
Browser Name : Firefox
Browser UserAgent : Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/17.0 Firefox/17.0
Callback : False
------------------------------------------------------------------------------------------------------------------------
(00023981){GuessSA.exe } [00424981] System.SysUtils.Sysutils.ConvertErrorFmt$qqrp20System.TResStringRecpx14System.TVarRecxi + $19
(00024DE0){GuessSA.exe } [00425DE0] System.SysUtils.Sysutils.StrToInt$qqrx20System.UnicodeString + $2C
(0033D777){GuessSA.exe } [0073E777] Main.TformMain.IWButton1Click$qqrp14System.TObject (Line 44, "Main.pas" + 2) + $3
(00224539){GuessSA.exe } [00625539] IWBaseControl.TIWBaseControl.DoClick$qqrv (Line 261, "IWBaseControl.pas" + 2) + $C
(00264F19){GuessSA.exe } [00665F19] IWCompButton.TIWButton.Submit$qqrx20System.UnicodeString (Line 118, "IWCompButton.pas" + 2) + $5
(0028AE03){GuessSA.exe } [0068BE03] IWForm.TIWForm.ExecuteForm$qqrv (Line 1090, "IWForm.pas" + 89) + $6
(002BC630){GuessSA.exe } [006BD630] IWApplication.TIWApplication.ExecuteActiveForm$qqrp23System.Classes.TStrings (Line 835, "IWApplication.pas" + 28) + $5
(002C3ED9){GuessSA.exe } [006C4ED9] IWServerSession.TIWServerSession.ExecuteForm$qqrv (Line 482, "IWServerSession.pas" + 6) + $C
(002C3AD8){GuessSA.exe } [006C4AD8] IWServerSession.TIWServerSession.ExecuteSession$qqr20System.UnicodeString (Line 443, "IWServerSession.pas" + 38) + $3
(002C0648){GuessSA.exe } [006C1648] IWServer.TIWServer.ExecuteUrl$qqrx20System.UnicodeString (Line 375, "IWServer.pas" + 41) + $8
(002C0ACF){GuessSA.exe } [006C1ACF] IWServer.TIWServer.Execute$qqrv (Line 422, "IWServer.pas" + 11) + $11
(002C179B){GuessSA.exe } [006C279B] IWServerSession.HttpExecute$qqrpuci (Line 77, "IWServerSession.pas" + 2) + $3
(0032E53B){GuessSA.exe } [0072F53B] IW.Server.HTTPIndy.Server.Httpindy.THTTPServerIndy.DoCommandGet$qqrp20Incontext.TInContextp37Incustomhttpserver.TInHTTPRequestInfop38Incustomhttpserver.TInHTTPResponseInfo (Line 176, "IW.Server.HTTPIndy.pas" + 19) + $28
(00316BCA){GuessSA.exe } [00717BCA] InCustomHTTPServer.TInCustomHTTPServer.DoExecute$qqrp20Incontext.TInContext (Line 1303, "InCustomHttpServer.pas" + 161) + $F
(002E8BC9){GuessSA.exe } [006E9BC9] InContext.TInContext.Run$qqrv (Line 169, "InContext.pas" + 2) + $9
(002E860A){GuessSA.exe } [006E960A] InTask.TInTask.DoRun$qqrv (Line 111, "InTask.pas" + 1) + $5
(00300AED){GuessSA.exe } [00701AED] InThread.TInThreadWithTask.Run$qqrv (Line 608, "InThread.pas" + 1) + $6
(003002FB){GuessSA.exe } [007012FB] InThread.TInThread.Execute$qqrv (Line 363, "InThread.pas" + 43) + $5
(000C4E86){GuessSA.exe } [004C5E86] System.Classes.ThreadProc$qqrp22System.Classes.TThread + $42
(00008AD4){GuessSA.exe } [00409AD4] System.ThreadWrapper$qqspv + $28
------------------------------------------------------------------------------------------------------------------------

 

Terms of Use | Privacy Statement © 2002 - 2024 Atozed Software