This documentation is for an old version of fiftyfive-wicket (2.0.9).


fiftyfive.wicket.util
Class LoggingUtils

java.lang.Object
  extended by fiftyfive.wicket.util.LoggingUtils

public class LoggingUtils
extends Object

Utility methods for logging detailed information about Wicket's internal state for troubleshooting purposes. Most of these methods work only when called within a Wicket thread.

Since:
2.0

Method Summary
static String describeActiveSessions()
          Returns a string that describes the active sessions in this format: 5 (16 peak).
static String describeMemoryUsage()
          Returns a string that describes the JVM's memory conditions in this format: 36M used, 29M free, 533M max.
static String describeRequestStep()
          Returns a human-readable description of the task currently being performed by the Wicket framework.
static String describeRequestTarget()
          Returns a description of component or page that is currently being processed by the Wicket framework.
static String dumpWicketState()
          Returns a multi-line string that describes the current Wicket request cycle in great detail.
static Map<String,Object> getApplicationInfo()
          Returns a Map with information associated with the following keys: Active Sessions (if IRequestLogger is enabled) Memory Usage IP Address Uptime (if app is a FoundationApplication)
static String getHostIpAddress()
          Returns the IP address hosting this JVM, or null if it could not be determined.
static Duration getRequestDuration()
          Returns the amount of time the current request has taken up until this point.
static Map<String,Object> getRequestInfo()
          Returns a Map with information associated with the following keys: URL Step Target Duration
static Duration getSessionDuration()
          Returns the amount of time the currently session has been active.
static Map<String,Object> getSessionInfo()
          Returns a Map with information associated with the following keys: ID Info (if session implements RequestLogger.ISessionLogInfo) Size Duration (if IRequestLogger is enabled)
static void logRuntimeException(org.slf4j.Logger logger, RuntimeException e)
          Writes to the logger a best-guess at the most concise description of the exception by first unwrapping it (see upwrap), then writes a large amount of information regarding the current Wicket state (see dumpWicketState), and finally writes the full stack traces of the entire exception chain.
static Throwable unwrap(RuntimeException e)
          Attempts to find the most meaningful exception in a runtime exception chain by stripping away the exceptions commonly used as "wrappers", namely: RuntimeException, WicketRuntimeException, InvocationTargetException and ExecutionException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

logRuntimeException

public static void logRuntimeException(org.slf4j.Logger logger,
                                       RuntimeException e)
Writes to the logger a best-guess at the most concise description of the exception by first unwrapping it (see upwrap), then writes a large amount of information regarding the current Wicket state (see dumpWicketState), and finally writes the full stack traces of the entire exception chain.

Example logger output:

 IllegalStateException: Attempt to set model object on null model of component: form:calendar-control:date-text-field
 
 Request:
   URL      = /form?wicket:interface=:0:form::IFormSubmitListener::
   Step     = Processing Form Submission
   Target   = FormTestPage > Form [form]
   Duration = 9 milliseconds
 Session:
   ID       = wvz6xha0fvdzte1x36zzbz4a
   Info     = Custom session information
   Duration = 16 seconds
   Size     = 13.5K
 Application:
   Active Sessions = 1 (6 peak)
   Memory Usage    = 36M used, 29M free, 533M max
   IP Address      = 172.16.1.14
   Uptime          = 33.5 seconds
 Headers:
   Host            = localhost:8080
   User-Agent      = Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5
   Accept          = application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
   Referer         = http://localhost:8080/form?initialMonth=10.2007&startDate=10.01.2007&endDate=11.10.2007
   Accept-Language = en-us
   Accept-Encoding = gzip, deflate
   Cookie          = JSESSIONID=wvz6xha0fvdzte1x36zzbz4a
   Connection      = keep-alive
   Origin          = http://localhost:8080
   Content-Type    = application/x-www-form-urlencoded
   Content-Length  = 47
 
 WicketMessage: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component [MarkupContainer [Component id = form]] threw an exception
 
 Root cause:
 
 java.lang.IllegalStateException: Attempt to set model object on null model of component: form:calendar-control:date-text-field
      at org.apache.wicket.Component.setDefaultModelObject(Component.java:3111)
      at org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1168)
      at org.apache.wicket.markup.html.form.Form$FormModelUpdateVisitor.component(Form.java:229)
      at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:514)
      at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493)
      at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493)
      at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrder(FormComponent.java:465)
      at org.apache.wicket.markup.html.form.Form.internalUpdateFormComponentModels(Form.java:2110)
      at org.apache.wicket.markup.html.form.Form.updateFormComponentModels(Form.java:2078)
      at org.apache.wicket.markup.html.form.Form.process(Form.java:1028)
      at org.apache.wicket.markup.html.form.Form.process(Form.java:955)
      at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:920)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182)
      at org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
      at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
      at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
      at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
      at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1436)
      at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
      at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:484)
      at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:317)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:83)
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
      at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
      at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
      at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
      at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
      at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440)
      at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
      at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
      at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at org.mortbay.jetty.Server.handle(Server.java:326)
      at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
      at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
      at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
 
 
 Complete stack:
 
 org.apache.wicket.WicketRuntimeException: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component [MarkupContainer [Component id = form]] threw an exception
      at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:193)
      at org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
      at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
      at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
      at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
      at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1436)
      at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
      at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:484)
 
 java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182)
      at org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
      at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
      at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
      at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
      at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1436)
      at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
      at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:484)


unwrap

public static Throwable unwrap(RuntimeException e)
Attempts to find the most meaningful exception in a runtime exception chain by stripping away the exceptions commonly used as "wrappers", namely: RuntimeException, WicketRuntimeException, InvocationTargetException and ExecutionException. These four exception types are usually language cruft that don't add much desciptive value.

For example, if the exception chain is:

 WicketRuntimeException
 -> InvocationTargetException
    -> MyBusinessException
       -> SQLException

Then the unwrapped exception would be MyBusinessException.


dumpWicketState

public static String dumpWicketState()
Returns a multi-line string that describes the current Wicket request cycle in great detail. Example output:
 Request:
   URL      = /form?wicket:interface=:0:form::IFormSubmitListener::
   Step     = Processing Form Submission
   Target   = FormTestPage > Form [form]
   Duration = 9 milliseconds
 Session:
   ID       = wvz6xha0fvdzte1x36zzbz4a
   Info     = Custom session information
   Duration = 16 seconds
   Size     = 13.5K
 Application:
   Active Sessions = 1 (6 peak)
   Memory Usage    = 36M used, 29M free, 533M max
   IP Address      = 172.16.1.14
   Uptime          = 33.5 seconds
 Headers:
   Host            = localhost:8080
   User-Agent      = Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-us) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5
   Accept          = application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
   Referer         = http://localhost:8080/form?initialMonth=10.2007&startDate=10.01.2007&endDate=11.10.2007
   Accept-Language = en-us
   Accept-Encoding = gzip, deflate
   Cookie          = JSESSIONID=wvz6xha0fvdzte1x36zzbz4a
   Connection      = keep-alive
   Origin          = http://localhost:8080
   Content-Type    = application/x-www-form-urlencoded
   Content-Length  = 47

Note that session duration and application active sessions are only available if Wicket's request logging facility is enabled.


getRequestInfo

public static Map<String,Object> getRequestInfo()
Returns a Map with information associated with the following keys:


getSessionInfo

public static Map<String,Object> getSessionInfo()
Returns a Map with information associated with the following keys:


getApplicationInfo

public static Map<String,Object> getApplicationInfo()
Returns a Map with information associated with the following keys:


describeRequestStep

public static String describeRequestStep()
Returns a human-readable description of the task currently being performed by the Wicket framework. The result will be one of these strings:


describeRequestTarget

public static String describeRequestTarget()
Returns a description of component or page that is currently being processed by the Wicket framework. If a component is being executed, the description will be in the form:
 PageClass > ComponentClass (superclass if component is anonymous) [wicket:id path]

Example:

 MyPage > MyPanel$1 (Link) [path:to:link]

If a page is being rendered, the description will be the page class.


getRequestDuration

public static Duration getRequestDuration()
Returns the amount of time the current request has taken up until this point.


getSessionDuration

public static Duration getSessionDuration()
Returns the amount of time the currently session has been active. Depends on Wicket's IRequestLogger being enabled. If it is not, returns null.


getHostIpAddress

public static String getHostIpAddress()
Returns the IP address hosting this JVM, or null if it could not be determined.


describeMemoryUsage

public static String describeMemoryUsage()
Returns a string that describes the JVM's memory conditions in this format: 36M used, 29M free, 533M max.


describeActiveSessions

public static String describeActiveSessions()
Returns a string that describes the active sessions in this format: 5 (16 peak). This information comes from the application's IRequestLogger. If the logger is not enabled, returns null.



Copyright © 2011 55 Minutes. All Rights Reserved.