Section B.8. Testing Logging


B.8. Testing Logging

Now that we've developed all the logging code and infrastructure, let's test the application to ensure that everything still works properly. Here are the steps to build and deploy the application:

  • Type ant in the root directory of appb to build the project.

  • Shut down JBoss so the Ant script can clean up the JBoss deployment area.

  • Type ant colddeploy to deploy the EAR file (jaw.ear) to the $JBOSS_HOME/server/default/deploy directory. Notice that the Ant build script also creates the logfile directory (specified by log4j.log.dir in the log4j.extra.properties file).

  • Start JBoss back up.

The Initialization Servlet runs at startup time, and you should see this message in the JAW Motors logfile, ${log4j.log.dir}/jbossatwork.log:

 2005-06-06 17:24:02,923 INFO  [com.jbossatwork.InitServlet] - Testing Logging Setup ... 

Now point your browser to http://localhost:8080/jawthis takes you to the JAW Motors home page. After running a credit check and buying a car, the log messages in the ${log4j.log.dir}/jbossatwork.log file should now look like this:

 2005-06-06 17:24:02,923 INFO  [com.jbossatwork.InitServlet] - Testing Logging Setup ... 2005-06-06 17:25:19,163 INFO  [com.jbossatwork.ControllerServlet] - Credit Check: 2005-06-06 17:25:19,163 INFO  [com.jbossatwork.ControllerServlet] - Name = [Tom] 2005-06-06 17:25:19,163 INFO  [com.jbossatwork.ControllerServlet] - SSN = [[345834[958[34]] 2005-06-06 17:25:19,163 INFO  [com.jbossatwork.ControllerServlet] - Email = [fred@acme.org] 2005-06-06 17:25:19,293 INFO  [com.jbossatwork.ejb.CreditCheckProcessorBean] - CreditCheckProcessorBean.onMessage(  ): Received message. 2005-06-06 17:25:19,293 INFO  [com.jbossatwork.ejb.CreditCheckProcessorBean]-- Credit Check: 2005-06-06 17:25:19,293 INFO  [com.jbossatwork.ejb.CreditCheckProcessorBean]--Name = [Tom] 2005-06-06 17:25:19,293 INFO  [com.jbossatwork.ejb.CreditCheckProcessorBean] - SSN = [[345834[958[34]] 2005-06-06 17:25:19,293 INFO  [com.jbossatwork.ejb.CreditCheckProcessorBean]-- Email = [fred@acme.org] 2005-06-06 17:25:19,303 INFO  [com.jbossatwork.ejb.CreditCheckProcessorBean]-- Verifying Credit ... 2005-06-06 17:25:26,804 INFO  [com.jbossatwork.ejb.CreditCheckProcessorBean]-- Credit Check Result = [Pass Credit Check] 2005-06-06 17:25:26,844 INFO  [com.jbossatwork.ejb.CreditCheckProcessorBean]-- Sending Email to [fred@acme.org] ... 2005-06-06 17:25:48,465 INFO  [com.jbossatwork.ControllerServlet] - carId = [99], price = [13500.0] 



JBoss at Work. A Practical Guide
JBoss at Work: A Practical Guide
ISBN: 0596007345
EAN: 2147483647
Year: 2004
Pages: 197

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net