coder and technology lover
AIR Logging Framework
Get the library
The library is available here: doc_logging_framework.swc
Download the AIR application example
I also realized a dummy AIR application which can be used to test the library, you can download it here: LogAppSample
API Documentation
I documented the swc classes by using asdoc tool, the documentation is available here
About
AIR Logging Framework is a Flex library I wrote to extend the default logging framework, in order to write log messages to files on the disk and provide a custom Flex’s UI component (which can be easy used into every AIR application) to read/filtering these log files.
These are the features it offers:
- Write unlimited log message to file (LogWriter)
- Read log messages from file… even big file beyond 20Mb! (LogReader)
- Automated backup creation of log files after a specific number of Kilobytes (BackupManager)
- Automated display and filtering (by date, message type, class type) of logged messages thanks to a simple UI component which extends Flex’s Window class (LogWindow).
- Provide access to internal events (you can add event handlers to several framework’s events)
To use the library, all you need to do is to add the swc under your Flex’s library path (into the AIR project you are working on).
Then you use Flex’s logging framework as you usually do and instead of choose a log target provided by “mx.logging.targets” package, you can use LogFileTarget under “com.daveoncode.logging” package.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // get LogFileTarget's instance (LogFileTarget is a singleton) var target:LogFileTarget = LogFileTarget.getInstance(); // The log file will be placed under applicationStorageDirectory folder target.file = File.applicationStorageDirectory.resolvePath("myApp.log"); // optional (default to "MM/DD/YY") target.dateFormat = "DD/MM/YY"; // optional (default to 1024) target.sizeLimit = 2048; // Trace all (default Flex's framework features) target.filters = ["*"]; target.level = LogEventLevel.ALL; // Begin logging (default Flex's framework features) Log.addTarget(target); |
Optionally you can add event listeners to the BackupManager:
1 2 3 4 5 | // BackupManager is a singleton class (like LogFileTarget) var manager:BackupManager = BackupManager.getInstance(); manager.addEventListener(BackupManagerEvent.BACKUP_CREATION_SUCCESS, this.backupHandler); manager.addEventListener(BackupManagerEvent.BACKUP_CREATION_FAILURE, this.failureHandler); |
And/or define your own LogWriter for LogFileTarget (it’s automatically created if you don’t specify one), in order to add event listeners to it:
1 2 3 4 5 6 | 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; |
Then, to easily see logs from your AIR application, you have to create a NativeMenuItem, a Button or what you prefer that will create and display a LogWindow (from “com.daveoncode.logging.ui” package):
1 2 3 4 5 | var window:LogWindow = new LogWindow(); window.title = "Application logs"; window.width = 800; window.height = 600; window.open(true); |
The window will looks like this:

24, Sunday f, 2009 - 10:47 pm
Hi,
Can you please make the source code available for us. When I am trying to sample an example I am getting ‘abc bytecode decoding ‘error. What is this? I don’t know.
25, Monday f, 2009 - 12:27 am
Which line of code is throwing the error? Could you show me the code you have written?
7, Tuesday f, 2009 - 7:06 am
How would you import this to an Air app using Javascript?
7, Tuesday f, 2009 - 12:26 pm
You can’t, this is a library for Flex, not Javascript :P
2, Friday f, 2009 - 7:44 am
Davide:
Did you package it as a swc or swf? I didn’t find a swc in the doc_logging_framework-1.0.zip file, which makes it impossible for to use it in my AIR application project.
Thanks,
Terry
2, Friday f, 2009 - 7:54 am
The zip file contains only one file: “doc_logging_framework-1.0.swc”… I don’t understand your issue :P
20, Tuesday f, 2009 - 7:05 pm
@Terry
Hi Davide,
did you manage to get the .swc file. I can see a lot of files inside the zip file but no .swc.
Thanks,
Lars
21, Wednesday f, 2009 - 12:29 am
You should download the swc from here: http://www.daveoncode.com/_dave_stuff/doc_logging_framework-1.0.zip (at the top of the page I wrote “get the library – The library is available here: doc_logging_framework.swc”)… if you see a lot of files, maybe you have downloaded the example AIR application (not the library) and you don’t have AIR installed on your machine (so LogAppSample.air appears as a folder rather than an executable file), you can get AIR here: http://get.adobe.com/air/ …I hope I was clear :)
13, Friday f, 2009 - 7:32 am
Hello,
1) when i try to use LogWindow as in your example, i got following error on opening.
RangeError: Error #1125: The index 1 is out of range 1.
at com.daveoncode.logging.io::DataLoader/textToObject()[C:\Documents and Settings\dzanotti\My Documents\Flex Builder 3\doc_logging_framework\src\com\daveoncode\logging\io\DataLoader.as:61]
at com.daveoncode.logging.io::DataLoader/timerHandler()[C:\Documents and Settings\dzanotti\My Documents\Flex Builder 3\doc_logging_framework\src\com\daveoncode\logging\io\DataLoader.as:95]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.utils::Timer/tick()
I guess it is because it doesn’t know where log info are ?
From your API doc, you wrote :
var lw:LogWindow = new LogWindow();
lw.logFile = File.applicationStorageDirectory.resolvePath(“myApp.log”);
but this method doesn’t seeem to exist.
Did you publish your sample application code so i get a working example ?
2) How can I log my own message
i tried something like : target.logEvent(new LogEvent(“hello world “, LogEventLevel.FATAL));
but it doesn’t seem the right way
thanks
Michel
13, Friday f, 2009 - 9:42 am
@Michel: the method exists, read here:
http://livedocs.adobe.com/flex/3/langref/flash/filesystem/File.html
To log your message, read how the default Flex logging framework works (see
mx.logging package), then use a LogFileTarget (provided by my extension).
Unfortunately, I’m loosing my Flex skills, because I’m not using it anymore and I
can’t help be so helpful :(
15, Sunday f, 2009 - 2:43 pm
Hi,
1) i don’t talk about File API but about your LogWindow API.
lw.logFile is referenced in your API help, but it doesn’t appear when using your object and self completion (“lw.” doesn’t show this method).
So how do you tell the logwindow where to read log file ?
2) I found it , thanks
it was:
var mylog:ILogger = Log.getLogger(“com.a7.ged.GED”);
if (Log.isDebug())
mylog.debug(“coucou”);
Michel
24, Wednesday f, 2010 - 1:57 am
have the same problem like Michel…
RangeError: Error #1125: The index 1 is out of range 1.
at com.daveoncode.logging.io::DataLoader/textToObject()[C:\Documents and Settings\dzanotti\My Documents\Flex Builder 3\doc_logging_framework\src\com\daveoncode\logging\io\DataLoader.as:61]
at com.daveoncode.logging.io::DataLoader/timerHandler()[C:\Documents and Settings\dzanotti\My Documents\Flex Builder 3\doc_logging_framework\src\com\daveoncode\logging\io\DataLoader.as:95]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.utils::Timer/tick()
could you publish your code of the swc/ code of the LogAppSample? would be really nice…I want to use your logging framework.
Cheers,
Iggy