my application uses servlets, EJBs, and a resource adapter. i have custom logging needs for a single servlet, 2 EJBs (a SLSB wrapping a BMP EB), and a single resource adapter. our logging mechanism does not require/use log4j. there should be a total of 3 log files - one for the servlet, one for both EJBs, and one for the resource adapter. a single instance of our custom logger should be instantiated for each of the 3 components/files.
currently my servlet instantiates its logger instance in init() after reading in all necessary properties from web.xml, while my resource adapter instantiates a static logger instance in ManagedConnectionFactory.createConnectionFactory, after getting the needed configuration parameters from its datasource file. in both of these cases there was a common entry point so it was relatively easy to construct the required logger and pass it to other components that needed it.
what's the best way to install such a custom logger for use by my EJBs? at this time i'm not concerned with EJBs distributed across cluster nodes, so we can rely on the EJBs living in a single JVM. the best i can think of is to have a static variable in my SLSB that is initialized (with synchronization) in setSessionContext. i think that will take care of my SLSB...not sure how best to pass this to my EB. i suppose i could add a setEJBLogger method to my Home interface, and call it immediately after every lookup of the EB.
any other ideas/suggestions are appreciated. in particular i'm not sure whether using synchronized in an EJB is legit.