LoggerLayoutTTCC

The TTCC layout format was taken from Apache log4j, and originally consisted of Time, Thread, Category and nested diagnostic Context information, hence the name.

LoggerLayoutTTCC contains equivalent information:

  • Time
  • Process ID
  • Logger name
  • Nested diagnostic context

Output of LoggerLayoutTTCC is identical to that of LoggerLayoutPattern with the conversion pattern set to %d{m/d/y H:i:s,u} [%t] %p %c %x - %m%n.

Parameters

The following parameters are available:

Parameter Type Required Default Description
threadPrinting boolean No true If set to true, the process ID will be included in output.
categoryPrefixing boolean No true If set to true, the logger name will be included in output.
contextPrinting boolean No true If set to true, the nested diagnostic context will be included in output.
microSecondsPrinting boolean No true If set to true, the microseconds will be included in output.
microSecondsPrinting string No %c Overrides the date format, using the format used in PHP strftime() function.

Examples

Configuration:

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

Running the following code:

Logger::configure("config.xml");
$logger = Logger::getLogger('myLogger');
$logger->info("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
$logger->debug("Donec a diam lectus.");
$logger->warn("Sed sit amet ipsum mauris.");

Produces the following output:

INFO - My first message.
DEBUG - My second message.
WARN - My third message.