Moved on log5f.org

Please, visit the new home page – log5F.org

Configuration

From beginning Log5F uses predefined external XML files for configuration. But from version 1.0 Log5F can be configured from custom external XML files or from XML objects.

Predefined XML files

Log5F tries to load configuration from these predefined URLs `{bin-dir}/log5f.xml` *or* `{bin-dir}/log5f.properties`. So if Log5F can load `log5f.xml` it can’t try to load `log5f.configuration`, but it try to load `log5f.configuration` if loading `log5f.xml` is fail.

Custom Configuration

Log5F allows to customize configuration through the `Log5FConfigurator` class, that provides API for add URLs of custom configuration files.

Log5FConfigurator API

Log5FConfigurator has next `static` fields:

Log5FConfigurator.ready

A flag that indicates if Log5F is configured and ready to use.

Log5FConfigurator.traceErrors

A flag that indicates if Log5F throw an error messages to trace.

Log5FConfigurator.configure(source:Object, force:Boolean):void;

Allows to add url of an external configuration file, whereupon it will be loaded before loading of the predefined files.
Also it method configures Log5F from the specified in `source` data, if it isn’t a string.

Parameters:

  • source Contains a configuration data, can be XML or string. If it is a XML it will used for configuration immediately, if it is a string it will used as an url to load configuration data.
  • force Inidicates if need to start loading XML data from specified url in `source` at once.

Example:


Log5FConfigurator.configure("configuration.xml");

Note: If source is not string configuration starts immediately, otherwise configuration starts only when Log5F is really used.

Configuration from XML

From version 1.0 is possibility to configure Log5F from XML, just pass to Log5FConfigurator.configure method XML in first parameter:

var config:XML = 
<configuration xsi:noNamespaceSchemaLocation="log5f.properties.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:log5j="http://log5f.org">
  <root level="ERROR" appenders="firebug"/>
  <logger name="com.example" level="DEBUG" 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} %c{1} - %m%n" type="String"/>
	</param>
  </appender>
</configuration>;

Log5FConfigurator.configure(config);

Note: If source is not string configuration starts immediately.

Configuration via FlashVars

From version 1.0 Log5F finds URL to configuration file in FlashVars, see more.

This page on project’s wiki.

Configure Log5F via FlashVars

From version 1.0 Log5F can get url of the configuration file from the FlashVars. To configure Log5F from custom file use log5f parameter in HTML, for example:

<object id="index" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="100%" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
    <param name="FlashVars" value="log5f=path_to_config.xml" />
    <param name="src" value="index.swf" />
    <param name="name" value="index" />
    <embed id="index" type="application/x-shockwave-flash" width="100%" height="100%" src="index.swf" name="index" flashvars="log5f=path_to_config.xml"></embed>
</object>

See more about it on a Wiki Page.

Version 1.0 in development

Currently I work on next version of the Log5F, that will add some features to make configuration process easier. I use trunk folder for work with this version, but now this code is note stable. So if you need a source code of the stable version of the Log5F, please use next url:

http://log5f.googlecode.com/svn/tags/0.5
Follow

Get every new post delivered to your Inbox.