As EJB's cannot directly acess the file system:
one solution for logging to text file from EJB is write some Helper(Java) class.
First put the log4j.properties file in one location like C://log4j/log4j.properties
In log4j.properties you have to mention where the log file has to be created.
In helper class:
Logger logger=Logger.getLogger("some string val");
PropertyConfigurator.configure("/log4j/log4j.properties");--this will read the log4j.properties file.
write a method which creats Logger object and return the logger to calling method.
In your EJB call this method and get the logger.
From this logger you can write debug or error or warn statements.
You can use the same class from servlet also.
Let me know if u have any Questions.
[ December 08, 2004: Message edited by: Praveena Venigalla ]