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?
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.
Internet Applications Division
then we need someone to capture the log, how if I want the logging process to be done automatically to the file?
here is the solution to your problem: http://www.log4j.org
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.
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.