Quick links: Content - sections - sub sections


jLog is a class which offers an api to trace, log messages or dump variables to a log output. The log output can be a classic file, syslog, firebug or other ways. jLog supports plugins to add targets (called "loggers"), and is used to log error messages too.

jLog declares two static methods:

  • jLog::log($message, $logType) to write a message
  • jLog::dump($variable, $message, $logType) to write a variable content (concretely it calls var_export)

The default logger is the file logger. Messages are stored into var/log/messages.log, or var/log/errors.log for errors. $logType (optional) indicate the type of the message. Each type is associated to one or more specific "loggers".

Configuring jLog

To specify loggers, you must fill the [logger] section (in app/system/mainconfig.ini.php or var/config/localconfig.ini.php). By default:

_all =
error= file

Options names are types of messages. You can choose any name for type of message, although some are reserved:

  • default: logger by default
  • error, warning, notice, deprecated, strict: used by the error manager, for error messages.
  • sql, for jDb (in dev edition), to log sql queries
  • soap, for jSoapClient, to log soap messages

And values are list of loggers (names of corresponding plugins). You can indicate :

  • file to store in files. File names are indicated in a [filelogger] section.
  • syslog to send messages to syslog
  • firebug, to displays messages into the javascript console of the browser (years before, it was possible only with the extension Firebug of Firefox, this is why its name).
  • mail, to send messages in a mail box
  • memory, to store messages in memory (temporary). It is needed for the debugbar or other components.
  • stdout and stderr to send log to the standard output and error output.
  • and any other plugin names you created or installed for jLog.

To not output sensitive data into logs

In log content of errors and other type of log, http requests parameters are dumped, to ease the debugging. However some of these data may be sensitive data, like the content of a password file of a form.

Since Jelix 1.6.16, it is possible to indicate in controllers and in the configuration which parameters should not be write into logs.

In the error_handling section of the configuration, you can add a sensitiveParameters parameters indicating a list of parameters name separated by a coma. By default, it has this value:

sensitiveParameters = "password,passwd,pwd"

You can indicate also other sensitive parameters into controllers, like this:

class passwordCtrl extends jController {

    public $sensitiveParameters = array('pwd', 'pwd_confirm');

    // ...

Note that jForms automatically declare all "secret" controls as sensitive data.

File logger

When you use the file logger, you must indicate in which file you want to store messages. Files are indicated into the [filelogger] section. Options are type of messages, and values are filenames (Into var/log/).

Example (default values):


To ease collaboration development on a same server, it is also possible to distinguish each developer logs. The only requirement is a unique ip per developer. Just use "%ip%" pattern in the log output filename.

default = "messages_%ip%.log"
news = "%ip%_modulenews.log"

If a developer works on host, his logs will be var/log/ and var/log/messages_192.168.1.2.log.

Date and time can also be used in log filenames. Just include some of : %Y% (year), %m% (month), %d% (day), %H% (hour) pattern in log filenames.

mail logger

To configure the mail logger, you should indicate the email and some headers, in the configuration:

email = root@localhost
emailHeaders = "Content-Type: text/plain; charset=UTF-8\nFrom: webmaster@yoursite.com\nX-Mailer: Jelix\nX-Priority: 1 (Highest)\n"

Avoid to use the mail logger, unless you know that your application is stable and errors are rare. Else you could receive tons of mails.

The debug bar

Jelix provides a debugbar, which displays every error messages and their details, and also many other informations: session data, sql queries etc. Each of these informations are provided by plugins. You can create your own plugins to enhance the debugbar.

The debugbar is a plugin itself for jResponseHtml. So to activate it:

  • You must declare the "debugbar" plugin in the list of plugins of jResponseHtml
  • you need to indicate the list of plugins you want to use for the debugbar (by default : "sqllog, sessiondata, defaultlog").

Here is a typical example to set into var/config/localconfig.ini.php:

plugins = debugbar

plugins = sqllog,sessiondata,defaultlog
defaultPosition = right

defaultPosition indicate if you want to display the debugbar on the left, on the right or at the center (center) of the web page. You could also change the position dynamically.

errors_openon indicates the error level that triggers the opening of the list of messages. Possible values, separated by a coma, are error, warning, notice, deprecated and strict, or * to say "all levels".

Emails sending

jMailer has parameters allowing to not send emails, or to send all of them to specific persons.

See the chapter about jMailer.