Logging in EJB


EJB design: Logging in EJB

  1. Logging in EJB (5 messages)

    From the EJB spec 1.1, section 18.1.2. It mentioned that an enterprise bean must not use the java.io package to access files and directories in the file system. Then how can I do the logging to a file?

    Threaded Messages (5)

  2. Logging in EJB[ Go to top ]

    You could log to a JDBC Connection legally. In EAServer we suggest ppl log to System.out which we capture and redirect to a log file.

    Dave Wolf
    Internet Applications Division
  3. Logging in EJB[ Go to top ]

    then we need someone to capture the log, how if I want the logging process to be done automatically to the file?
  4. Logging in EJB[ Go to top ]

    here is the solution to your problem: http://www.log4j.org/

  5. Logging in EJB[ Go to top ]

    Thx for your suggestion, for still because of the EJB specification, I can't log the logs from the java.io packages to the file.
  6. Logging in EJB[ Go to top ]

    The section of the Spec to which you refer begins with this:

    "This section describes the programming restrictions that a Bean Provider must follow to ensure that the
    enterprise bean is portable and can be deployed in any compliant EJB Container...."

    I do not believe this is a hard-and-fast requirement of the Specification. We have several EJB applications deployed using Weblogic that use LOG4J for application logging.

    In general you should be careful with file operations to minimize any compatibility issues you may encounter. Encapsulate file operations into appropriate classes. Use file.separator when constructing file paths. The java.io package itself is designed to be abstract with respect to the VM implementation so if you use some common sense you should be fine.