Creating my own appender

32 views
Skip to first unread message

Brenda

unread,
Oct 21, 2009, 11:00:28 AM10/21/09
to log5f
I've written a simple ActionScript class that extends from Appender:

package south.logging.appenders {

import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.filesystem.File;
import flash.filesystem.FileStream;

import org.log5f.Appender;
import org.log5f.events.LogEvent;

import turner.logging.appenders.*;

public class TextFileAppender extends Appender {

public function TextFileAppender() {
super();
}
// writes to a text file
o
o
o
}

The properties file is, in part:
<appender name="chainsaw"
class="south.logging.appenders.TextFileAppender">
<param name="layout" value="org.log5f.layouts.Log4JLayout"
type="Class" />
<param name="filename" value="TextFile.txt" />
</appender>

The className, "south.logging.appenders.TextFileAppender", is being
passed to the method 'getDefinitionByName', PropertyConfigurator.as,
correctly, but it's throwing a "ReferenceError". From what I've read,
that means that Flash can't find the class 'TextFileAppender'.

Any comments or suggestions?

Thanks!
Brenda

Max Rozdobudko

unread,
Oct 21, 2009, 11:35:06 AM10/21/09
to lo...@googlegroups.com
Hi, Brenda!

This because your class doesn't uses in application, and flex comp

- use "includes" compiler's option to include your appender (-incl
- use "forceCompile" method of LoggerManager (LoggerManager.forceC

or use any other techniques for compile your class in application.

bhamilton

unread,
Oct 21, 2009, 1:56:14 PM10/21/09
to lo...@googlegroups.com
Max,

Thank you again!  Using the 'includes' compiler option took care of that.

Now I have to figure out why the log4j formatter can't get the application loader information.  The error, in part is:

SecurityError: Error #2119: Security sandbox violation: caller app:/log5fExamples.swf cannot access LoaderInfo.applicationDomain owned by app:/log5fExamples.swf.
    at flash.display::LoaderInfo$/getLoaderInfoByDefinition()
    at org.log5f.layouts::Log4JLayout/getApplicationURL()[/Users/<user>/Documents/Adobe Flash Builder Beta 2/log5f/Log5FLib/src/org/log5f/layouts/Log4JLayout.as:77]

Since the log5f.swc is included in the projects library, shouldn't it have access to that information?

Brenda

2009/10/21 Max Rozdobudko <max.roz...@gmail.com>

Max Rozdobudko

unread,
Oct 22, 2009, 3:52:38 AM10/22/09
to lo...@googlegroups.com
Hi, Brenda. I can't reproduce this issue, do you can attach sample application here? But I think what this error is not handled this is a bug, and I added catching of this error in Log5F.

Brenda

unread,
Nov 19, 2009, 9:59:07 AM11/19/09
to log5f
I'm sorry that I'm so late getting back here. I got pulled off onto
something else.

I avoided the issue with where a file can be written by prepending the
file name(s) with 'File.documentsDirectory.nativePath +
File.separator'. Of course this restricts where the files can be
written but permissions problems are avoided.

Thanks for your help!
Brenda
Reply all
Reply to author
Forward
0 new messages