Menu

Different log levels for different loggers

Help
bobby_peru
2006-03-14
2013-04-17
  • bobby_peru

    bobby_peru - 2006-03-14

    I would like to be able to set up logging so that I can log "ALL" to a LuminicBox logger, and "WARNING" to server post logger. This is for all classes, not based on the package/class (or hierarchy, if I understand it correctly).

    Loggers in the classes are currently set up:
    oLogger:Logger = LogManager.getLogger("com.re.etc.ClassName");

    I've tried setting two SimpleHierarchicalLogger's with the appropriate handlers, but can only get a RootLogger to work.

    We've been using AS2LIB logging for a while now and is really cool.

    Bobby

     
    • Simon Wacker

      Simon Wacker - 2006-03-14

      Hi Bobby,

      you may use the LevelFilterHandler for this purpose.
      Add a SimpleHierarchicalLogger instance with name 'com.re' (or something like that) to the logger hierarchy.
      The logger instance must be added the LuminicBoxHandler plus the handler that logs to the server. But you do not add the server handler directly, but wrap it with a LevelFilterHandler instance. If you set the filter level to warning, warning, error and fatal messages will get through the filter, all other levels will be filtered out.

      Does this serve your needs?

      There is currently no support for only allowing one specific message level to go through, but I can easily add this behaviour if you need it.

      Greetings,
      Simon

      PS: Nice to hear that you like as2lib logging. ;)

       
    • bobby_peru

      bobby_peru - 2006-03-16

      Thanks, that's great. I hadn't noticed the LevelFilterHandler amongst the other LogHandlers. I'm using the RootLogger rather than the SimpleHierarchicalLogger because I don't really need to control the logging on a class or package level - is that the way to use the RootLogger?

      Here's the LevelFilterHandler usage in case anyone else wants it:

      var oLuminicHandler:LogHandler = new LuminicBoxHandler();
      oLevelFilterHandler = new LevelFilterHandler(oLuminicHandler, AbstractLogLevel.WARNING);
      oLogger.addHandler(oLevelFilterHandler);

       
    • Simon Wacker

      Simon Wacker - 2006-03-16

      Hi Bobby,

      the RootLogger extends the SimpleHierarchicalLogger which was specifically created to work with the LoggerHierarchy.
      If you don't need hierarchy support I suggest you to use the SimpleLogger which is uses log handlers but does not implement the HierarchicalLogger and ConfigurableHierarchicalLogger interfaces. This may save you about 1kb and is also a little faster. ;)

      Greetings,
      Simon

       
    • Vladimir Tsvetkov

      Could you give me some basic samples how to use the speed tests testing framework. By now I've used only the unit testing framework in as2lib, and I will find it very usefull if you give me some guidelines on how to do some speed testing too.

      Best Regards,
      Vladimir

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.