LoggerLayoutHTML formats the log as an HTML document.


The following parameters are available:

Parameter Type Required Default Description
locationInfo boolean No false If set to true, adds the file name and line number at which the log statement originated.
title string No Log4php Log Messages Sets the <title> of the generated HTML document.



  • XML
  • PHP
<configuration xmlns="http://logging.apache.org/log4php/">
    <appender name="default" class="LoggerAppenderEcho">
        <layout class="LoggerLayoutHtml">
            <param name="locationInfo" value="true" />
        <appender_ref ref="default" />
    'appenders' => array(
        'default' => array(
            'class' => 'LoggerAppenderEcho',
            'layout' => array(
                'class' => 'LoggerLayoutHtml',
    'rootLogger' => array(
        'appenders' => array('default')

Running the following code:

$log = Logger::getRootLogger();
$log->debug("Hello World!");
$log->info("Hello World!");

Produces the output as a HTML table:

Time Thread Level Category File:Line Message
0 5868 DEBUG root D:\Projects\apache\log4php-config-adapters\src\examples\php\layout_html.php:23 Hello World!
2 5868 INFO root D:\Projects\apache\log4php-config-adapters\src\examples\php\layout_html.php:24 Hello World!

Source of the output:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <title>Log4php Log Messages</title>
    <style type="text/css">
    body, table {font-family: arial,sans-serif; font-size: x-small;}
    th {background: #336699; color: #FFFFFF; text-align: left;}
<body bgcolor="#FFFFFF" topmargin="6" leftmargin="6">
<hr size="1" noshade>
Log session start time 09/22/11 13:19:23<br>
<table cellspacing="0" cellpadding="4" border="1" bordercolor="#224466" width="100%">
        <td title="5868 thread">5868</td>
        <td title="Level"><font color="#339933">DEBUG</font></td>
        <td title="root category">root</td>
        <td title="Message">Hello World!</td>
        <td title="5868 thread">5868</td>
        <td title="Level">INFO</td>
        <td title="root category">root</td>
        <td title="Message">Hello World!</td>