Title: RE: [JBoss-user] log4j+JBoss
I have a grand total of about 18 hrs experience with log4j, so put the following remarks in that context, but what you discuss below doesn't put the power and flexibility to maximum use.  Here is the total of the statements needed in the EJB code:
 
import org.apache.log4j.Category;
 
public class OurBean implements SessionBean
   {
   private final Category log = Category.getInstance(getClass().getName());
   public void ourMethod()
       {
       log.info("ourMethod called");
       }
   }
 
Everything else you show below can be configured in log4j.properties in the jboss/conf directory.  That way, your logging code is independent of its final format and destination.  You can change the format and destination without making a single change to your source code.
 
To the original appender, log4j is already installed.  Just use the above statements in your source.  Then configure how you want your output to look and where you want it to go in log4j.properties.  The existing one will get you started.  Finally, you need to update jboss.conf to disable consolelogging and filelogging and enable log4j.  All  the statements are already in the file, just comment and uncomment.  From trial and error, you can't comment by just surrounding the block of statements with <!-- and -->.  The statements are executed anyway.  You need to remove the starting <.
 
Documentation for log4j can be found at http://www.apache.org/foundation/projects.html.  Look for log4j and follow the links.
----- Original Message -----
Sent: Wednesday, May 23, 2001 9:46 AM
Subject: RE: [JBoss-user] log4j+JBoss

You should be able to use log4j the same way as you do for any class. See the examples on the Log4J docs.

This is my code on a state-full session bean,


file://*** IMPORT AS NEEDED ***//
import org.apache.log4j.Category;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.Layout;
import org.apache.log4j.FileAppender;
import org.apache.log4j.PropertyConfigurator;

//** ON MY ejbCreate **//

    //set logging options
    try{
      Layout layout = new PatternLayout("%d{HH:mm:ss,SSS}%r [%t] %c %x - %m%n");
      cat.addAppender(new FileAppender(layout,"C:/temp/your.log",true));
      cat.info("Started Log for EJB");
    } catch(IOException e){
      isDebug = false;
    };


___________________________
Paul Jaime
[EMAIL PROTECTED]
___________________________

 -----Original Message-----
From:   Isidoro Fernandez Diaz [mailto:[EMAIL PROTECTED]]
Sent:   Wednesday, May 23, 2001 9:03 AM
To:     [EMAIL PROTECTED]
Subject:        [JBoss-user] log4j+JBoss


        Hi!

                I need to download log4j for JBoss... Can help me anybody?
                Also I need to learn how to install and to configure log4j for JBoss.

        Thanks folks. Bye.

Isidoro Fern�ndez D�az
mailto:[EMAIL PROTECTED]
Software Engineer
TELENIUM, The New Millennium Telecom Company
Agust�n de Fox�, 25, plta. 13
28036 MADRID
Tel. +34 91 315 85 62
Fax +34 91 315 63 37
http://www.telenium.es


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to