1 Reply Latest reply on Aug 6, 2012 3:34 PM by Will Lam

    Creating a separate log on JBoss, but is empty.

    Will Lam Newbie

      Hi,

       

      I have a simple SOAP based application writing to a separate log.  The log is created under jboss/bin/log, but it's empty. I deploy the web services as a jar file to JBoss AS 6.1.   The log4j.properties is under the root directory of ‘src’ folder.

       

      package abc.WebServiceSamples;

       

      import java.io.IOException;

      import java.io.InputStream;

       

      import java.util.Properties;

       

      import javax.jws.WebMethod;

      import javax.jws.WebService;

      import javax.ejb.Stateless;

       

      import org.apache.log4j.Logger;

      import org.apache.log4j.PropertyConfigurator;

       

      @Stateless

      @WebService(serviceName = "GreetingService")

      public class greeting {

          static final Logger logger = Logger.getLogger(greeting.class);

       

          public greeting() {

              super();

          }

       

          @WebMethod

          public String welcome(String s1) {

              String str = "Welcome,  " + s1;

       

              Properties props = new Properties();

       

              //load from classpath

              InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("log4j.properties");

       

              // Now pass these properties to PropertyConfigurator

              try {

      props.load(inputStream);

              } catch (IOException e) {

      e.printStackTrace(System.out);

              }

      PropertyConfigurator.configure(props);

       

       

      logger.debug("Sample debug message");

      logger.info("Sample info message");

      logger.warn("Sample warn message");

      logger.error("Sample error message");

      logger.fatal("Sample fatal message");

       

              return str;

          }

       

      }

       

      log4j.properties:

       

      log4j.rootLogger=INFO

       

      # AdminFileAppender - used to log messages in the admin.log file.

      log4j.appender.AdminFileAppender=org.apache.log4j.FileAppender

      log4j.appender.AdminFileAppender.File=log/admin.log

      log4j.appender.AdminFileAppender.layout=org.apache.log4j.PatternLayout

      log4j.appender.AdminFileAppender.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

       

      # ReportFileAppender - used to log messages in the report.log file.

      log4j.appender.ReportFileAppender=org.apache.log4j.FileAppender

      log4j.appender.ReportFileAppender.File=log/report.log

      log4j.appender.ReportFileAppender.layout=org.apache.log4j.PatternLayout

      log4j.appender.ReportFileAppender.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

       

      #log4j.logger.com.vaannila.admin=,AdminFileAppender

      log4j.logger.abc.WebServiceSamples.greeting=,ReportFileAppender

       

      Thank you,

       

      Will

        • 1. Re: Creating a separate log on JBoss, but is empty.
          Will Lam Newbie

          java run command:

           

          /opt/java/bin/java -server -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=true -Dprogram.name=run.sh -Dlogging.configuration=file:/opt/jboss/bin/logging.properties -Dlog4j.debug=true -Djava.library.path=/opt/jboss/bin/native/lib64 -Djava.endorsed.dirs=/opt/jboss/lib/endorsed -classpath /opt/jboss/bin/run.jar:/opt/java/lib/tools.jar org.jboss.Main -c all -b 0.0.0.0

           

          tailing server/all/server.log:

           

          2012-08-06 15:21:33,688 INFO [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (HDScanner) deploy, ctxPath=/ejb_ws_greeting

          2012-08-06 15:21:50,929 INFO [STDOUT] (Finalizer) log4j: Finalizing appender named [OtherAppender].

          2012-08-06 15:21:50,930 INFO [STDOUT] (Finalizer) log4j: Finalizing appender named [ReportFileAppender].

          2012-08-06 15:22:37,156 INFO [org.apache.cxf.transport.servlet.AbstractCXFServlet] (http-0.0.0.0-8080-1) Servlet transport factory already registered

          2012-08-06 15:22:37,164 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Parsing for [root] with value=[INFO].

          2012-08-06 15:22:37,165 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Level token is [INFO].

          2012-08-06 15:22:37,169 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Category root set to null

          2012-08-06 15:22:37,169 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Parsing for [abc.WebServiceSamples.greeting] with value=[WARN,ReportFileAppender ].

          2012-08-06 15:22:37,169 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Level token is [WARN].

          2012-08-06 15:22:37,169 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Category abc.WebServiceSamples.greeting set to null

          2012-08-06 15:22:37,169 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Parsing appender named "ReportFileAppender".

          2012-08-06 15:22:37,170 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Parsing layout options for "ReportFileAppender".

          2012-08-06 15:22:37,170 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Setting property [conversionPattern] to [%-4r [%t] %-5p %c %x - %m%n].

          2012-08-06 15:22:37,171 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: End of parsing for "ReportFileAppender".

          2012-08-06 15:22:37,171 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Setting property [file] to [log/report1.log].

          2012-08-06 15:22:37,171 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: setFile called: log/report1.log, true

          2012-08-06 15:22:37,171 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: setFile ended

          2012-08-06 15:22:37,171 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Parsed "ReportFileAppender" options.

          2012-08-06 15:22:37,171 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Handling log4j.additivity.abc.WebServiceSamples.greeting=[null]

          2012-08-06 15:22:37,172 INFO [STDOUT] (http-0.0.0.0-8080-1) log4j: Finished configuring.

          2012-08-06 15:22:37,172 INFO [STDOUT] (http-0.0.0.0-8080-1) Welcome, Hi  cool

          2012-08-06 15:22:37,172 WARN [abc.WebServiceSamples.greeting] (http-0.0.0.0-8080-1) Sample warn message

          2012-08-06 15:22:37,172 ERROR [abc.WebServiceSamples.greeting] (http-0.0.0.0-8080-1) Sample error message

          2012-08-06 15:22:37,172 FATAL [abc.WebServiceSamples.greeting] (http-0.0.0.0-8080-1) Sample fatal message