thanks, but the point is that all java classes are running inside WebSphere.
How come I get the output from normal java classes, but not from ejb bean
classes?

here is the way how I use Log4J.

/**
 * Bean Implementation class of UtilityMgr Stateless Session EJB
 */

public class UtilityMgrBean implements SessionBean {
    /**
     * logger
     */
    private static final LogHelper log = new
LogHelper(UtilityMgrBean.class);


    ....
    ....
        if (log.isDebugEnabled())
            log.debug("log is enabled");
}
        

Then I have LogHelper class defined as below. Btw, I found also in EJB
class, return category.isDebugEnabled() is not working.

public class LogHelper implements 
{
   
   /**
    * Is the logging instance initialized.
    */
   private static boolean initialized = false;
   
   /**
    * Logging Category
    */
   private Category category = null;
   
   public LogHelper(Class component) 
   {
         super();
         
         // Initialize the logging system if required
         if (!initialized) 
                init();
                
         category = Category.getInstance(component);    
   }

   public void debug(Object obj) 
   {
           category.debug(obj);    
   }

   public void debug(Object obj, Exception e) 
   {
     category.debug(obj, e);    
   }

   public void error(Object obj) 
   {
     category.error(obj);    
   }

   public void error(Object obj, Exception e) 
   {
     category.error(obj, e);    
   }

   public void info(Object obj) 
   {
     category.info(obj);    
   }

   public void info(Object obj, Exception e) 
   {
     category.info(obj, e);    
   }

   private static synchronized void init() 
   {
           if (!initialized) {
                   // Get the configuration from the property file
                   PropertyConfigurator.configureAndWatch(MY_LOG_FILE,
MY_REFRESH_RATE);
                   initialized = true;
           }    
   }

   public boolean isDebugEnabled() 
   {
        // Somehow the following line is not working in EJB bean
      return category.isDebugEnabled();    
   }

   public boolean isInfoEnabled() 
   {
        // Somehow the following line is not working in EJB bean
      return category.isInfoEnabled();    
   }

   public void warn(Object obj) 
   {
     category.warn(obj);    
   }

   public void warn(Object obj, Exception e) 
   {
     category.warn(obj, e);    
   }
}

Thanks.

-----Original Message-----
From: Bellamy, Scot [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 03, 2002 1:43 PM
To: Log4J Users List
Subject: RE: Use Log4J with WebSphere


I don't believe that Log4J violates the EJB spec, unless you use it in
such a way that it does.  Section EJB.18.1.2 contains a list of
programming restrictions for bean providers.  In that section it states
"An enterprise bean must not use the java.io package to attempt to
access files and directories in the file system."  

I'm not sure if Webshpere allows violation of the specification or not.
There are a couple of ways to work around this, however.

1.  You can use the JDBC appender to write log information to a
database.  Since JDBC is part of the J2EE specification this is fully
complient.

2.  You can create a logging service that runs in a separate process and
utilize JMS to send messages from your EJB beans to the logging service.

Scot.


-----Original Message-----
From: Michael Wang (IT) [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, April 03, 2002 1:30 PM
To: 'Log4J Users List'
Subject: Use Log4J with WebSphere


I'ved asked this question before.

Now my problem is my Log4J works fine with any classes except EJB beans
class. Any idea about how to configure WebSphere 4.0?

I run my J2EE app within WebSphere for a while. Then I examine my log
output file, it has all necessary output from any java classes except
EJB beans. I vaguely remember awhile back somebody mentioned that Log4J
violates EJB spec. Do I need to configure my WebSphere 4.0 to allow
access to the file (the output is file). Thanks.


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

Reply via email to