1 Reply Latest reply on Dec 7, 2003 10:26 AM by jamesstrachan

    JBoss EJB & Log4j

    sbrytskyy Newbie

      How to implement custom logging into separate log file from my ejb? Where can i see simple example of config file and ejb?
      Can I configure my ejb with attached log4j.properties or I can configure it by conf/log4j.xml file only? How can I configure priorities of logging, how to choose needed category from mu ejb?

      I am using next fragment of code in my ejb:
      import net.sf.hibernate.expression.Order;
      private static Category log = Category.getInstance(SessionFacadeDeviceBean.class);
      log.debug("Retrieving devices list.");
      but can't see result nowhere :-(
      Thanks for advice.

        • 1. Re: JBoss EJB & Log4j
          jamesstrachan Newbie

          Please find attached a log4j configuration file that :-

          a) Creates a separate file-based appender MILTONAPPLOG with a threshold of "DEBUG" to enable output of DEBUG messages;

          b) Creates a console appender MILTONCONSOLE with a threshold of "DEBUG" to enable output of DEBUG messages to console;

          c) Creates a logger that logs all Log4J output from packages starting "org.milton" to both MILTONCONSOLE and MILTONAPPLOG;

          d) sets the threshold value on the "org.milton" logger to INFO to enable logging at INFO level.

          e) Prevents duplication of output in standard and MILTON appenders by setting additivy="false" in the "org.milton" logger.

          f) Creates a second nested logger that enables debug level output from packages starting "org.milton.services" to the same appenders as "org.milton".

          If you are not seeing DEBUG level output, that is probably because your existing appenders have a threshold that disables DEBUG output.

          This, or similar, should be used to replace conf/log4j.xml. I don't think that you can set up a separate configuration file, but you hardly need to when you can tweak the main configuration file by adding nested loggers at any level of granularity.