Core Documentation

Here you will find the new official reference manuals. These documents are related to the core of TYPO3 and address the built in functionality of TYPO3. They are designed to provide you with in-depth information.

Old Core Documentation


9.2. 
Configuration

All configuration options related to error and exception handling are found in $TYPO3_CONF_VARS[SYS]:

Key

Datatype

Description

displayErrors

integer

Configures whether PHP errors should be displayed.

  1. 0 = Do not display any PHP error messages. Overrides the value of “exceptionalErrors” and sets it to 0 (= no errors are turned into exceptions),the configured “productionExceptionHandler” is used as exception handler

  2. 1 = Display error messages with the registered error handler, the configured “debugExceptionHandler” is used as exception handler

  3. 2 = Display errors only if client matches TYPO3_CONF_VARS[SYS][devIPmask]. If devIPmask matches the users IP address  the configured “debugExceptionHandler” is used  for exceptions, if not  “productionExceptionHandler” will be used.

  4. -1 = Default setting. With this option, you can override the PHP setting "display_errors". If devIPmask matches the users IP address  the configured “debugExceptionHandler” is used  for exceptions, if not “productionExceptionHandler” will be used.

errorHandler

string

Classname to handle PHP errors. Leave empty to disable error handling.

Default: “t3lib_error_ErrorHandler”. This class will register itself as error handler. It is able to write error messages to all available logging systems in TYPO3 (t3lib_div::syslog, t3lib_div::devlog() and to the sys_log table).

Additionally the errors can be displayed as flash messages in the Backend or in the adminpanel in Frontend. The flash messages in Backend are only displayed if the error and exception handling is in “debug-mode”, which is the case when the configured “debugExceptionHandler” is registered as exception handler (see: TYPO3_CONF_VARS[SYS][displayErrors]).

Errors which are registered as “exceptionalErrors” will be turned into exceptions (to be handled by the configured exceptionHandler).

errorHandlerErrors

integer

The E_* constant that will be handled by the error handler

Default:  E_ALL ^ E_NOTICE

exceptionalErrors

integer

The E_* constant that will be handled as an exception by the error handler.

Default: "E_ALL ^ E_NOTICE ^ E_WARNING ^ E_USER_ERROR ^ E_USER_NOTICE ^ E_USER_WARNING" (4341) and "0" if displayError=0.

Refer to the PHP documentation for more details on this value.

productionExceptionHandler

string

Classname to handle exceptions that might happen in the TYPO3-code.

Leave empty to disable exception handling.

Default: “t3lib_error_ProductionExceptionHandler”. This exception handler displays a nice error message when something went wrong. The error message is logged to the configured logs.

Note: The configured productionExceptionHandler is used if displayErrors is set to “0” or to “-1” and devIPmask doesn't match.

debugExceptionHandler

string

Classname to handle exceptions that might happen in the TYPO3-code.

Leave empty to disable exception handling.

Default: “t3lib_error_DebugExceptionHandler”. This exception handler displays the complete stack trace of any encountered exception. The error message and the stack trace  is logged to the configured logs.

Note: The configured debugExceptionHandler is used if displayErrors is set to “1” and if displayErrors is “-1”  or “2” and the devIPmask matches.

enable_errorDLOG

boolean

Whether errors should be written to the developer log (requires an installed *devlog extension).

enable_exceptionDLOG

boolean

Whether exceptions should be written to the developer log (requires an installed *devlog extension).

syslogErrorReporting

integer

Configures which PHP errors should be logged to the configured syslogs (see: [SYS][systemLog]). If set to "0" no PHP errors are logged to the syslog. Default is "E_ALL ^ E_NOTICE" (6135).

belogErrorReporting

integer

Configures which PHP errors should be logged to the "syslog" table (extension: belog). If set to "0" no PHP errors are logged to the sys_log table. Default is "E_ALL ^ E_NOTICE" (6135).

The table below shows which values can be set by the user and which are set by TYPO3.

Values in black can be changed in localconf.php.

Values in red are set by TYPO3.

display

Errors

errorHandler

Errors

exceptionalErrors

errorHandler

devIP

mask

exception

Handler

display_

errors (php_ini)

-1

E_ALL

^ E_NOTICE

E_ALL

^ E_NOTICE

^ E_WARNING

^ E_USER_ERROR

^ E_USER_NOTICE

^ E_USER_WARNING

t3lib_error_ErrorHandler

match

$TYPO3_CONF_VARS['SYS']['debugExceptionHandler']

Not changed

no match

$TYPO3_CONF_VARS['SYS']['productionExceptionHandler']

     

0

E_ALL

^ E_NOTICE

0 (no errors are turned into exceptions)

t3lib_error_ErrorHandler

Doesn't matter

$TYPO3_CONF_VARS['SYS']['productionExceptionHandler']

0 (Off)

1

E_ALL

^ E_NOTICE

E_ALL

^ E_NOTICE

^ E_WARNING

^ E_USER_ERROR

^ E_USER_NOTICE

^ E_USER_WARNING

t3lib_error_ErrorHandler

Doesn't matter

$TYPO3_CONF_VARS['SYS']['debugExceptionHandler']

1 (On)

2

E_ALL

^ E_NOTICE

E_ALL

^ E_NOTICE

^ E_WARNING

^ E_USER_ERROR

^ E_USER_NOTICE

^ E_USER_WARNING

t3lib_error_ErrorHandler

match

$TYPO3_CONF_VARS['SYS']['debugExceptionHandler']

1 (On)

no match

$TYPO3_CONF_VARS['SYS']['productionExceptionHandler']

0 (Off)

    

t3lib_error_ErrorHandler

The class t3lib_error_ErrorHandler is the default error handler in TYPO3.

Functions:

  1. Can be registered for all, or for only a subset of the PHP errors which can be handled by an error handler

  2. Displays error messages as flash messages in the Backend (if exceptionHandler is set to “t3lib_error_DebugExceptionHandler”). Since flash messages are integrated in the Backend template, PHP messages will not destroy the Backend layout.

  3. Displays errors as TsLog messages in the adminpanel.

  4. Logs error messages to t3lib_div::syslog() which is able to write error messages to a file, to the web server's error_log, the system's log and it can send you errors and exceptions in an email.  t3lib_div::syslog() offers a hook and can be extended by user-defined logging methods.

  5. Logs error messages to t3lib_div::devLog() if “enable_errorDLOG” is enabled (depending on the devlog extension used, this might require an existing DB connection).

  6. Logs error messages to the sys_log table. Logged errors are displayed in the belog extension (Tools->Log) (works only if there is an existing DB connection).

t3lib_error_ProductionExceptionHandler

Functions of t3lib_error_ProductionExceptionHandler

  1. Shows brief exception message using t3lib_timeTrack::debug_typo3PrintError() which can be manipulated by a hook

  2. Logs exception messages to t3lib_div::syslog() which is able to write exception messages to a file, to the web server's error_log, the system's log and it can send you errors and exceptions in an email.  t3lib_div::syslog() offers a hook an can be extended by user-defined logging methods.

  3. Logs exception messages to t3lib_div::devlog() if “enable_exceptionDLOG” is enabled (depending on the devlog extension used, this might require an existing DB connection).

  4. Logs exception messages to the sys_log table. Logged errors are displayed in the belog extension (Tools->Log) (works only if there is an existing DB connection).

t3lib_error_DebugExceptionHandler

Functions of t3lib_error_DebugExceptionHandler

  1. Shows detailed exception messages and full trace of an exception

  2. Logs exception messages to t3lib_div::syslog() which is able to write exception messages to a file, to the web server's error_log, the system's log and it can send you errors and exceptions in an email.  t3lib_div::syslog() offers a hook an can be extended by user-defined logging methods.

  3. Logs exception messages to t3lib_div::devlog() if “enable_exceptionDLOG” is enabled (depending on the devlog extension used, this might require an existing DB connection).

  4. Logs exception messages to the sys_log table. Logged errors are displayed in the belog extension (Tools->Log) (works only if there is an existing DB connection).

Examples

Debugging and development setup

Very verbose configuration which logs and displays all errors and exceptions.

[File: localconf.php]

$TYPO3_CONF_VARS['SYS']['displayErrors'] = '1';
$TYPO3_CONF_VARS['SYS']['devIPmask'] = '*';
$TYPO3_CONF_VARS['SYS']['errorHandler'] = 't3lib_error_ErrorHandler';
$TYPO3_CONF_VARS['SYS']['errorHandlerErrors'] = E_ALL ^ E_NOTICE;
$TYPO3_CONF_VARS['SYS']['exceptionalErrors'] = E_ALL ^ E_NOTICE ^ E_WARNING ^ E_USER_ERROR ^ E_USER_NOTICE ^ E_USER_WARNING;
$TYPO3_CONF_VARS['SYS']['debugExceptionHandler'] = 't3lib_error_DebugExceptionHandler';$TYPO3_CONF_VARS['SYS']['productionExceptionHandler'] = 't3lib_error_DebugExceptionHandler';
$TYPO3_CONF_VARS['SYS']['systemLogLevel'] = '0';
$TYPO3_CONF_VARS['SYS']['systemLog'] = 'mail,test@localhost.local,4;error_log,,2;syslog,LOCAL0,,3;file,/abs/path/to/logfile.log';

$TYPO3_CONF_VARS['SYS']['enable_errorDLOG'] = '1';$TYPO3_CONF_VARS['SYS']['enable_exceptionDLOG'] = '1';

[File: .htaccess]

php_flag display_errors onphp_flag log_errors onphp_value error_log /path/to/php_error.log

Production setup

Example for a production configuration which displays only errors and exceptions if the devIPmask matches. Errors and exceptions are only logged if their level is at least 2 (=Warning).

[File: localconf.php]

$TYPO3_CONF_VARS['SYS']['displayErrors'] = '2';
$TYPO3_CONF_VARS['SYS']['devIPmask'] = '[your.IP.address]';
$TYPO3_CONF_VARS['SYS']['errorHandler'] = 't3lib_error_ErrorHandler';
$TYPO3_CONF_VARS['SYS']['systemLogLevel'] = '2';$TYPO3_CONF_VARS['SYS']['systemLog'] = 'mail,test@localhost.local,4;error_log,,2;syslog,LOCAL0,,3';

$TYPO3_CONF_VARS['SYS']['enable_errorDLOG'] = '0';$TYPO3_CONF_VARS['SYS']['enable_exceptionDLOG'] = '0';$TYPO3_CONF_VARS['SYS']['syslogErrorReporting'] = E_ALL ^ E_NOTICE ^ E_WARNING;$TYPO3_CONF_VARS['SYS']['belogErrorReporting'] = '0';

[File: .htaccess]

php_flag display_errors offphp_flag log_errors onphp_value error_log /path/to/php_error.log

Performance setup

Since the error and exception handling and also the logging need some performance, here's an example how to disable error and exception handling completely.

[File: localconf.php]

$TYPO3_CONF_VARS['SYS']['displayErrors'] = '0';
$TYPO3_CONF_VARS['SYS']['devIPmask'] = '';
$TYPO3_CONF_VARS['SYS']['errorHandler'] = '';
$TYPO3_CONF_VARS['SYS']['debugExceptionHandler'] = '';$TYPO3_CONF_VARS['SYS']['productionExceptionHandler'] = '';
$TYPO3_CONF_VARS['SYS']['systemLog'] = '';

$TYPO3_CONF_VARS['SYS']['enable_errorDLOG'] = '0';$TYPO3_CONF_VARS['SYS']['enable_exceptionDLOG'] = '0';$TYPO3_CONF_VARS['SYS']['syslogErrorReporting'] = '0';$TYPO3_CONF_VARS['SYS']['belogErrorReporting'] = '0';

[File: .htaccess]

php_flag display_errors offphp_flag log_errors off

Extending the error and exception handling

If you want to register your own error or exception handler, simply include the class and insert its name to “productionExceptionHandler”, “debugExceptionHandler” or “errorHandler”.

Example:

$TYPO3_CONF_VARS['SYS']['errorHandler'] = 'myOwnErrorHandler';
$TYPO3_CONF_VARS['SYS']['debugExceptionHandler'] = 'myOwnDebugExceptionHandler';$TYPO3_CONF_VARS['SYS']['productionExceptionHandler'] = 'myOwnProductionExceptionHandler';

An error or exception handler class must register an error (exception) handler in its constructor. Have a look at the files in t3lib/error/ to see how this should be done.

If you want to use the built-in error and exception handling but extend it by your own functionality, simply derive your class from the error and exception handling classes shipped with TYPO3 and register this class as error (exception) handler.

Example:

class tx_postExceptionsOnTwitter extends t3lib_error_DebugExceptionHandler {

    function echoExceptionWeb(Exception $exception) {
        $this->postExceptionsOnTwitter($exception);
    }
    function postExceptionsOnTwitter($exception) {
        // do it ;-)
    }

}

$TYPO3_CONF_VARS['SYS']['debugExceptionHandler'] = 'tx_postExceptionsOnTwitter';$TYPO3_CONF_VARS['SYS']['productionExceptionHandler'] = 'tx_postExceptionsOnTwitter';