AS3 logging with Log4j
April 9th, 2007There are several things I miss about FlexBuilder…the debugger, authoring-time error checking, code assistance, and the quick compiles to name a few. But perhaps the first thing you’ll miss when just using the free Flex SDK is your basic trace output window. Initially I had written a simple Ruby script to handle tracing to a terminal window. This was fine for awhile but as some of my projects grew bigger, I wanted more control over logging.
Flex comes with a logging system under the mx.logging package which works similarly to typical logging systems in other languages, it’ll categorize logs, provide log levels, and has some log filtering capabilities. So I changed my tracing class that connects to the Ruby script into a log target. This was much nicer since any code using the standard mx.logging package is now compatible just by add the target.
However something still bothered me, I didn’t like the filtering controls being done in ActionScript. I mean it’s nice to have, but I really don’t see why we have to re-code and re-compile just to view a different log category and/or level. Sure a nice little component could be made to handle this at runtime but that didn’t seem necessary either. Certainly there must be dozens of existing logging apps out there for doing just this.
After some digging, I found Apache’s Chainsaw v2 to be a good fit. It has the filtering features I wanted, it’s cross-platform (interestingly as a webstart on windows and linux but native for osx), it’s by a huge well respected organization, and it’s free. With a little work to create the Log4j based log messages and connection to Chainsaw, this logging target is now a part of my standard workflow and so I thought I’d share.
Features
- Log category and level filtering done externally at runtime
- Chainsaw features also include log message filtering by search query, builds category tree, customizing log presentation, and log saving/loading
- Log events are Log4j XML messages and should be able to tie with other compatible systems
Usage Example
After you’ve added the logging.swc to your project’s library path, the following example will log to Chainsaw.
package nochump.logdemo { import flash.display.Sprite; import mx.logging.*; import nochump.logging.target.Log4jXMLSocketTarget; public class LogDemo extends Sprite { protected static const logger:ILogger = Log.getLogger("nochump.logdemo.LogDemo"); Log.addTarget(new Log4jXMLSocketTarget()); public function LogDemo() { logger.debug("Hello debug message"); logger.info("Hello info message"); logger.warn("Hello warn message"); logger.error("Hello error message"); logger.fatal("Hello fatal message"); } }}
Before running the swf, fire up Chainsaw v2 and load the supplied log4jconf.xml file when it asks. This creates an XMLSocketReceiver which you should see in the receivers panel. Running the above example shows up in Chainsaw like the following.
Download
nochump-logging-10-dist.zip
Order viagra buying viagra uk
James thompson viagra lawsuit
Effects long phentermine side term
Pheniramine
Levofloxacin
Uk viagra supplier
Atenolol viagra
Viagra suppliers
Cephapirin
Buying viagra
Xanax grapefruit juice
Viagra online uk
Xanax drug test
Piperacillin
Phentermine delivered cod
Levivia viagra compared
Viagra online pharmacy
Addiction tramadol
Cialis compare levitra viagra
Alternative to viagra drug
Buy vicodin online
Yasmin
Xanax withdrawals
Viagra uk sales
Heparin
Liver problems from xanax
Phentermine without prescription and energy pill
Vicodin for sale
Toprol
Chlortetracycline
Eulexin
Phentermine weight loss medication
Order vicodin
Xanax fedex overnight
Troglitazone
Amantadine
Discount meridia
Dichlorphenamide
Phenolphthalein
Buy xanax overnight
Appetite suppressants and phentermine
Dangers of taking phentermine
Tricor
Order phentermine online uk
Buy fioricet
Aspirin
Bretylium
Lethal dosage of xanax
Methocarbamol
Femara
Zoloft
Atenolol
Buy Valtrex
Lamictal
Diazepam
Pharmacies ship phentermine c.o.d method
Cod diet phentermine pill
Buy phentermine online com
Cefaclor
Phenylephrine
Discount priced viagra
Long term effects of xanax
Mixing viagra and cialis
Cheap tramadol cod
Monopril
Mefloquine
Physical symptoms of high blood pressure and xanax
Ambien withdrawal
Viagra alternative and woman
Viagra dangers
Xanax and pregnancy
Doxorubicin
Cialis reviews
No prescription phentermine free shipping
Lopressor
Tools needed for injecting xanax
Methixene
Thiothixene
Hydrocodone information
Ecotrin
Adipex phentermine vs
Xanax in early pregnancy
Prevacid
Phentermine effects
Phentermine c.o.d. Tomorrow
Purchase cialis
Cialis generic
Hydrocodone vicodin
Soma restaurant
Cytarabine
Cheap online order viagra
Xanax withdrawl
Hyzaar
Diltiazem
Imitrex
Discount phentermine no prescription
Acetaminophen e hydrocodone
Xanax 2mg
Nitrofurantoin
Lanoxin
Chlorpheniramine
Dangers of phentermine heart
Anileridine
Ethoheptazine
Fioricet order
Herbal online viagra
Low price phentermine
Phentermine 37.5 mg diet pills
Phentermine addiction
Order phentermine online without perscription
Tramadol apap
Imiquimod
Buy cheap purchase uk viagra
Xanax libido
Chloramphenicol
Viagra libido
How much xanax is a lethal dose
Xanax death
Methadone and xanax
Buy cheap domain online atspace com xanax
Hydrocodone online
Arthrotec
Levorphanol
Phentermine chemical enhancement
Phentermine pill town
Cialis experience
Discount cialis
Paxil with phentermine interactions
Viagra overdose
Ativan
Buy cheap domain online outdoors com xanax
Cheep phentermine
Coumadin
Letrozole
Discount viagra online
Online pharmacies phentermine xenical meridia
Buy phentermine shipped usps
Prescription for viagra
Betaxolol
Viagra
Hydrocodone overdose
Aprobarbital
Zestoretic
Combivent
Maximum dosage of phentermine
Dienestrol
Glimepiride
Tramadol medication
Fatal dose of xanax
Cetirizine