Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

eZDebug and logging

Write to the debug output and log files from an extension - writeNotice, writeWarning, writeError, writeDebug, timing and accumulators, eZLog::write - and the debug settings.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/extension-development/part-8-reference/ezdebug-and-logging.md

On this page

eZDebug and logging

Part 8, reference 3. eZDebug (lib/ezutils/classes/ezdebug.php) collects messages for the debug output and writes them to log files; eZLog (lib/ezfile/classes/ezlog.php) writes lines to a log file of your choice. How to read the output is in Debug output and logs for developers and Debugging extensions.

Messages

All are static and take the message, a label (usually __METHOD__) and an optional CSS class for the debug output:

MethodLevelLog file (under var/log/, or the site's log directory)
eZDebug::writeNotice( $string, $label = "", $backgroundClass = "" )noticenotice.log
eZDebug::writeWarning( $string, $label = "", $backgroundClass = "" )warningwarning.log
eZDebug::writeError( $string, $label = "", $backgroundClass = "" )errorerror.log
eZDebug::writeDebug( $string, $label = "", $backgroundClass = "" )debugdebug.log
eZDebug::writeStrict( $string, $label = "", $backgroundClass = "" )strictstrict.log

$string may be an array or object; it is printed readably.

<?php
eZDebug::writeNotice( 'Imported 12 items', __METHOD__ );
eZDebug::writeWarning( "Setting [ListSettings] Limit missing, using 10", __METHOD__ );
eZDebug::writeError( "Item $id not found", __METHOD__ );

Which levels end up in the log files is set in site.ini [DebugSettings]: AlwaysLog[] lists the levels written even when the debug output is off (by default error).

Timing

<?php
eZDebug::accumulatorStart( 'myext_import', 'myext', 'Import' );
// ... the work ...
eZDebug::accumulatorStop( 'myext_import' );

eZDebug::addTimingPoint( 'myext: before rendering' );
MethodShows
accumulatorStart( $key, $inGroup = false, $name = false, $recursive = false ) and accumulatorStop( $key, $recursive = false )the total time spent between start and stop, summed over calls, in the debug output's time accumulators
addTimingPoint( $description = "" )a point in the timing table with time and memory

Is the debug output on?

eZDebug::isDebugEnabled() returns whether debug output is collected for this request. Use it to skip expensive preparation of debug messages.

Your own log file

<?php
eZLog::write( "Order $orderID sent to the warehouse", 'myext.log' );

eZLog::write( $message, $logName = 'common.log', $dir = 'var/log' ) appends a dated line. Pass the site's log directory if your installation uses one (eZSys::varDirectory() . '/log'). Never write passwords, tokens or personal data into logs.

The settings

site.ini [DebugSettings]:

SettingEffect
DebugOutputenabled shows the debug output
DebugByIP, DebugIPList[]show it only to listed addresses
DebugByUser, DebugUserIDList[]show it only to the listed user IDs
AlwaysLog[]levels written to log files whatever the above say

Turn the debug output on only on development copies or for your own address.

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x