I am new to Java and J2EE and I am trying to determine how to best log server side error messages. I am currently evaluating Log4j as the tool to log the message. One of the attributes I would like to log is the userid with every error and as a result I have a few questions?
1)Is there a JAAS method to determine who the userid is in a Session Bean or an Entity Bean or do I need to pass this information.
2) What is best practices for this?
you can use the method getCallerPrincipal() on the sessionBeanContext, which is set by the container, if you bean have correct set-method.
by the method, mentioned above, you get the principal, which actually call the method at the momement. (use getName() getting the principal's name)
I hope, that helps