Avg. Rating 3.7

Problem

Our testers want to receive information about what is happening in the application in the Firebug console.

Solution

Use Log5F and FirebugAppender. And Firefox + Firebug plugin.

Detailed explanation

 For that we need:

1. Get Firefox

2. Get Firebug

3. Download Log5F and add it to project (for Flex/AIR based projects just copy Log5F.swc into /lib directory, for Flash projects see this link).

4. Create and configure log5f.configuration file, it must contains firebug appender and one or more loggers which used this appender, for example:

<?xml version="1.0" encoding="UTF-8"?>

<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="log5f.properties.xsd" xmlns:log5j="http://log5f.org">

<root level="ALL" appenders="firebug" />

<appender name="firebug" class="org.log5f.appenders.FirebugAppender">

<param name="layout" value="org.log5f.layouts.PatternLayout" type="Class">

<param name="conversionPattern" value="%d{ABSOLUTE} %5p %m" type="String" />

</param>

</appender>

</configuration>

in this example in log5f.properties file defines one FirebugAppender appender that used by root logger to append all messages from application into Firebug console in Firefox. File log5f.properties should be in  the bin-debug directory.

5. Using Log5F is very simple:

import mx.events.FlexEvent;

import org.log5f.Logger;

import org.log5f.LoggerManager;

private function applicationCompleteHandler(event:FlexEvent):void

{

var logger:Logger = LoggerManager.getRootLogger();

logger.debug("Hello Firebug!");

}

in this example using root logger, but you can create loggers for different categories.

Report abuse

Related recipes