• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

one error gets logged multiple times when using rootLogger

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my log4j properties, I've defined a rootLogger to log everything starting with WARN to a file, so I don't have to put logger.error(...) in every catch statement (the rootLogger catches the errors itself when they are thrown). But the problem is, that errors get logged multiple times. For example, when I throw an IOException, i get these two lines:

1:
ERROR (ApplicationDispatcher.java:687) - Servlet.service() for servlet action threw exception
java.io.IOException: dddd
(...stack trace)

2:
ERROR (StandardWrapperValve.java:253) - Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Exception forwarding for name index: java.io.IOException: dddd
(...stack trace)

And when I use a wrong key for bean:message tag (I use struts) the error is logged even 6 times. In short it looks like this:

ApplicationDispatcher.java:704) - Servlet.service() for servlet jsp threw exception
(InsertTag.java:922) - ServletException in '/tiles/body_search.jsp': Missing message for key "search..title"
(InsertTag.java:922) - ServletException in '/tiles/body_search.jsp': Missing message for key "search..title"
(ApplicationDispatcher.java:704) - Servlet.service() for servlet jsp threw exception
(ApplicationDispatcher.java:704) - Servlet.service() for servlet action threw exception
(StandardWrapperValve.java:253) - Servlet.service() for servlet jsp threw exception

The question is how can I assure that each error (incl. JspExceptions) will get logged only one time (with full trace)? Thanks for advice.
 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic