2 Replies Latest reply on Mar 27, 2008 10:29 AM by ereztison

    problem with null logger in interceptor

    aleroch

      HI All,


      I'm newbie with JBoss Seam and I have problem with logger in my own interceptor class. I use this POJO class for the @AroundInvoke purpose. I declared @Logger private Log log field for logger logic but in my interceptor method I always receive null for log instance:(


      Why I receive null ?What can be a reason of this wrong behavior ?


      Thanks,
      Alex



      import javax.interceptor.AroundInvoke;
      
      import javax.interceptor.InvocationContext;
      
      
      import org.jboss.seam.annotations.Logger;
      
      import org.jboss.seam.annotations.Name;
      
      import org.jboss.seam.log.Log;
      
      
      @Name("loggedInInterceptor")
      
      public class LoggedInInterceptor {
      
           
      
           @Logger
      
           private Log log;
      
           
      
           @AroundInvoke
      
           public Object checkLoggedIn(InvocationContext invocation) throws Exception {
      
                // log is null here :(
      
                return invocation.proceed();
      
           }
      
      }


        • 1. Re: problem with null logger in interceptor
          keithnaas

          Within Seam an Interceptor is not a Seam Component. It is a class that can intercept invocations on Seam Components.


          You may want to read 5.2. Seam interceptors to get a better understanding of how to write and apply interceptors to Seam components.

          • 2. Re: problem with null logger in interceptor
            ereztison

            Hi,


            There has been some time since the question has been asked but bumping this same need lead me to this question, and probably others as well.


            What I finally did is defining a class member of type org.jboss.seam.log.Log initialized by Logger.getLog(Class) method, as appears below:



            private Log log = Logging.getLog(ActivityTrackingInterceptor.class);
            



            This gives you an valid instance you can use


            Erez