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. 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 extension Firebug of Firefox.
  • mail, to send messages in a mail box
  • memory, to store messages in memory (temporary). It is needed for the debugbar or other components.
  • and any other plugin names you created or installed for jLog.

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:

plugins = debugbar

plugins = sqllog,sessiondata,defaultlog
defaultPosition = right

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