Hi Jacob,
thanks for your reply.

Checking in the log4j source code, i saw all log methods and all guard methods performs something like this:

   public boolean isTraceEnabled() {
       if (repository.isDisabled(Level.TRACE_INT)) {
           return false;
         }

         return Level.TRACE.isGreaterOrEqual(this.getEffectiveLevel());
   }

The repository level is set to ALL by default, so just overriding getEffectiveLevel() i'm able to have a per user level.

I developed my Logger and my LoggerFactory. The LoggerFactory is needed just to create and return instances of my Logger.
My Logger has just two methods:

  public
   Level getEffectiveLevel() {
     Level userLevel = getUserLevel((String)MDC.get("userName"));
     if (userLevel != null) {
         return userLevel;
     }
     for(Category c = this; c != null; c=c.getParent()) {
       if(c.getLevel() != null)
         return c.getLevel();
     }
     return null; // If reached will cause an NullPointerException.
   }

   private Level getUserLevel(String userName) {
        return _the_user_level;
   }


This way seems to work fine, but does anyone see some issue/problem/drawback ?

Thanks a lot
Ste


Jake

>Any help will is appreciated.
>Thanks in advance.
>
>Ste
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to