TIWExceptionLoggerThe 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.


  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