0

I have created a client that calls an EJB by JNDI. The EJB has logs (slf4j) that normally are printed to a log file. What I want to do when I run my client is to redirect ALL possible logs to the standard output.

I've tried with SimpleLogger. I added slf4-simple dependency and if I add logs on my client, they are printed on console but not the logs of the EJB.

Client:

private static final Logger logger = LoggerFactory.getLogger("the  EJB logger");

public static void main(String[] args) {

    logger.debug("testing...");  // this log is shown on console

    try {
        Environment env = new Environment();   // weblogic.jndi.Environment
        env.setProviderURL(EJB_HOST);
        Context ctx = env.getInitialContext();

        MyEjb ejb  = (MyEjb) (ctx.lookup(EJB_JNDI));
        ejb.foo();  // the logs of this method are not shown on console
    } catch (NamingException) {
        logger.error(e.getMessage(), e);
        System.exit(2);
    }

}
anat0lius
  • 2,145
  • 6
  • 33
  • 60
  • 2
    What you are trying to do is not possible this way. Your client and your EJB are using their own log configuration. Furthermore, if your EJB is remote, client and ejb will live in separate JVM. EJB specifications do not include any way to propagate ejb logs to the client. All you have are the return value and the exception if any. – Emmanuel Collin Feb 04 '19 at 10:57
  • @EmmanuelCollin I understand. Then maybe the best would be to add a console appender to the EJB logger. Thank you. – anat0lius Feb 04 '19 at 11:01

0 Answers0