1 Reply Latest reply on Oct 21, 2010 6:54 AM by zenocon

    Logging Woes - filtering not working as expected

    zenocon

      I have a Logger class (below), but I cannot get filtering to work as expected.  
      
      See below where I add two trace targets with different levels and filters.
      
      I want to filter mx.rpc.* and mx.messaging.* to ERROR level because they are very noisy.
      
      I want to filter my own package namespace to DEBUG.
      
      Unfortunately, this line ->
      
      
      addTarget(new TraceTarget(), ["mynamespace.*"], LogEventLevel.DEBUG);
      ...causes the log framework to output everything as DEBUG including mx.rpc.* and mx.messaging.*  What am I missing here? package mynamespace.log {                 import com.adobe.air.logging.FileTarget;            import flash.filesystem.File;      import flash.utils.getQualifiedClassName;            import mx.logging.ILogger;      import mx.logging.ILoggingTarget;      import mx.logging.Log;      import mx.logging.LogEventLevel;      import mx.logging.targets.LineFormattedTarget;      import mx.logging.targets.TraceTarget;       public class Logger {           private static var instance:Logger=new Logger();                      function Logger() {                if(instance != null) {                     throw new Error("singleton logger can't be instantiated");                }                // trace targets addTarget(new TraceTarget(), ["mx.messaging.*", "mx.rpc.*"], LogEventLevel.ERROR);                                                addTarget(new TraceTarget(), ["mynamespace.*"], LogEventLevel.DEBUG);           }                      private static function addTarget(target:LineFormattedTarget, filters:Array, level:int):void {                target.level = level;                target.includeCategory = true;                target.includeDate = true;                target.includeLevel = true;                target.includeTime = true;                target.filters = filters;                Log.addTarget(target);           }                      private function getInternalLog(classRef:Class):ILogger {                 var className:String = getQualifiedClassName(classRef).replace("::", ".");                return Log.getLogger(className);           }                      public static function getLogger(classRef:Class):ILogger {                return instance.getInternalLog(classRef);           }      } }