Hi, On Sat, Sep 1, 2012 at 12:20 PM, Dan Simko <wicke...@gmail.com> wrote: > Hi, > > I am looking for some solution how to log all exceptions in my code. I tried > to override onException method in RequestCycleListener but log file was full > of exceptions like this: > > org.apache.wicket.protocol.http.servlet.ResponseIOException: > ClientAbortException: java.net.SocketException: Broken pipe > > So I am thinking about something like this: > > private static Class[] KNOWN_EXCEPTIONS = > {ListenerInvocationNotAllowedException.class, ResponseIOException.class}; > > @Override > public IRequestHandler onException(RequestCycle cycle, Exception ex) { > HttpServletRequest request = (HttpServletRequest) > cycle.getRequest().getContainerRequest(); > if (ex instanceof PageExpiredException) { > LOG.debug(MessageFormat.format("PageExpiredException for request > ''{0}''", request.toString())); > }else if(isKnownException(ex)){ > LOG.warn(MessageFormat.format("InternalErrorPage for request > ''{0}'', Exception message ''{1}''", request.toString(), ex.getMessage())); > } else { > LOG.error(MessageFormat.format("InternalErrorPage for request > ''{0}''", request.toString()), ex); > } > return super.onException(cycle, ex); > } > > private boolean isKnownException(Exception ex) { > for (Class<? extends Throwable> clazz : KNOWN_EXCEPTIONS) { > if(Exceptions.findCause(ex, clazz) != null){ > return true; > } > } > return false; > } > > > Is this right approach? If yes, another question is how to deal with this > exception:
This is one way. Another is to create an extension to your preferred logging framework. For example http://logback.qos.ch/manual/filters.html Also I see that you use MessageFormat. SLF4J supports that for you : http://www.slf4j.org/manual.html - search for placeholders. > > 2012-08-17 09:58:43,184 [http-77.48.124.51-80-32] ERROR > c.w.web.WicketRequestCycleListener - InternalErrorPage for request > 'http://sportave.com/wicket/resource/com.wickeria.web.WickeriaApplication/jquery-and-wicket-ver-134BD6850DBC85F8DCBCD3A0DB7207C6.js' > java.lang.IllegalStateException: Header was already written to response! This exception should not be ignored. It means that you have written some data to the browser and then you tried to send an error code or try to redirect. This is not allowed. The browser may have already rendered the data so far. Better investigate why this happens and fix it. > at > org.apache.wicket.protocol.http.HeaderBufferingWebResponse.checkHeader(HeaderBufferingWebResponse.java:64) > ~[wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.protocol.http.HeaderBufferingWebResponse.sendError(HeaderBufferingWebResponse.java:105) > ~[wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.http.handler.ErrorCodeRequestHandler.respond(ErrorCodeRequestHandler.java:77) > ~[wicket-request-6.0-20120809.004719-1476.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:814) > ~[wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) > ~[wicket-request-6.0-20120809.004719-1476.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:302) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.executeExceptionRequestHandler(RequestCycle.java:311) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:225) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:281) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:245) > [wicket-core-6.0-20120809.004947-1468.jar:6.0-SNAPSHOT] > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > [catalina-6.0.35.jar:6.0.35] > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > [catalina-6.0.35.jar:6.0.35] > at > org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) > [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE] > at > org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) > [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE] > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) > [catalina-6.0.35.jar:6.0.35] > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > [catalina-6.0.35.jar:6.0.35] > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) > [catalina-6.0.35.jar:6.0.35] > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) > [catalina-6.0.35.jar:6.0.35] > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) > [catalina-6.0.35.jar:6.0.35] > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) > [catalina-6.0.35.jar:6.0.35] > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) > [catalina-6.0.35.jar:6.0.35] > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) > [catalina-6.0.35.jar:6.0.35] > at > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) > [tomcat-coyote-6.0.35.jar:6.0.35] > at > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) > [tomcat-coyote-6.0.35.jar:6.0.35] > at > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) > [tomcat-coyote-6.0.35.jar:6.0.35] > at java.lang.Thread.run(Thread.java:662) [na:1.6.0_26] > > > Can I prevent this exception? If not, would it be possible to change > IllegalStateException to some more specific wicket exception in order to > adding it to the KNOWN_EXCEPTIONS array? > > > Thank you very much! > > -- > You received this message because you are subscribed to the Google Groups > "brix-cms-discuss" group. > To post to this group, send email to brix-cms-disc...@googlegroups.com. > To unsubscribe from this group, send email to > brix-cms-discuss+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/brix-cms-discuss?hl=en. -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org