Packagecom.daveoncode.logging
Classpublic class LogFileTarget
InheritanceLogFileTarget Inheritance mx.logging.AbstractTarget

This class is the most important of com.daveoncode.logging package, it's objective is to extend Flex's loggin framework in order to write log messages to a file. It overrides mx.logging.AbstractTarget's logEvent() method, creates a LogRecord object and then uses the LogWriter class to write it to the file. Important: this class uses the Singleton design pattern, you can't create new instances of LogFileTarget, but you have to use getInstance() method to access to the only instance available.


Example

// LogFileTarget's configuration
var target:LogFileTarget = LogFileTarget.getInstance();

target.file = File.applicationStorageDirectory.resolvePath("myApp.log");
target.dateFormat = "DD/MM/YY"; // optional
target.sizeLimit = 2048; // optional

// Filter classes
target.filters = ["];

// Manually creation of a LogWriter for LogFileTarget in order to add event listener (optional)
var writer:LogWriter = new LogWriter(target.file, target.sizeLimit);

writer.addEventListener(LogWriterEvent.WRITE_SUCCESS, this.successHandler);
writer.addEventListener(LogWriterEvent.WRITE_FAILURE, this.failureHandler);

target.logWriter = writer;

// Log all levels
target.level = LogEventLevel.ALL;

// Begin logging
Log.addTarget(target);

See also

com.daveoncode.logging.ui.LogWriter


Public Properties
 PropertyDefined by
  dateFormat : String
A valid dateFormat string
LogFileTarget
  file : File
Log file
LogFileTarget
  logWriter : LogWriter
Returns the internal LogWriter object by allowing the user to attach event handlers to it
LogFileTarget
  sizeLimit : uint
Max file size
LogFileTarget
Public Methods
 MethodDefined by
  
The constructor function for LogFileTarget class.
LogFileTarget
  
[static] Returns the current LogFileTarget instance
LogFileTarget
  
logEvent(e:LogEvent):void
Handle the LogEvent received from Flex's logging framework by creating a new LogRecord which is then passed to LogWriter's write() method
LogFileTarget
Property detail
dateFormatproperty
dateFormat:String  [read-write]

A valid dateFormat string

Implementation
    public function get dateFormat():String
    public function set dateFormat(value:String):void
fileproperty 
file:File  [read-write]

Log file

Implementation
    public function get file():File
    public function set file(value:File):void
logWriterproperty 
logWriter:LogWriter  [read-write]

Returns the internal LogWriter object by allowing the user to attach event handlers to it

Implementation
    public function get logWriter():LogWriter
    public function set logWriter(value:LogWriter):void

See also

LogWriterEvent
sizeLimitproperty 
sizeLimit:uint  [read-write]

Max file size

Implementation
    public function get sizeLimit():uint
    public function set sizeLimit(value:uint):void
Constructor detail
LogFileTarget()constructor
public function LogFileTarget()

The constructor function for LogFileTarget class.

Method detail
getInstance()method
public static function getInstance():LogFileTarget

Returns the current LogFileTarget instance

Returns
LogFileTarget
logEvent()method 
public override function logEvent(e:LogEvent):void

Handle the LogEvent received from Flex's logging framework by creating a new LogRecord which is then passed to LogWriter's write() method

Parameters
e:LogEventThe event brodcasted by logging framework