0 Replies Latest reply on Mar 11, 2008 6:48 PM by Damian Harvey

    Javascript errors in server log

    Damian Harvey Apprentice

      I've been battling with Javascript errors from IE today - which is difficult on the Mac.

      After finding this article on Ajaxian I implemented it with Seam + Richfaces. All it does is log client side Javascript errors to your server log. It's not as useful as I thought it would be (still no help with IE's cryptic error messages) but I thought someone might like it.

      This code goes into your page (preferably in your global template where you can take it out before go live. Or not):

      <!-- other head stuff -->
           onerror= function handleErr(msg,url,l)
                logJavaScriptError(msg, url, l);
          <a:jsFunction action="#{javascriptLogger.error}" name="logJavaScriptError">
            <a:actionparam name="msg" assignTo="#{javascriptLogger.message}"/>
            <a:actionparam name="url" assignTo="#{javascriptLogger.url}"/>
            <a:actionparam name="l" assignTo="#{javascriptLogger.lineNumber}"/>

      And a component to log it:

      public class JavascriptLogger {
        private String message;
        private String url;
        private String lineNumber;
        public void setMessage(String message) {
          this.message = message;
        public void setUrl(String url) {
          this.url = url;
        public void setLineNumber(String lineNumber) {
          this.lineNumber = lineNumber;
        public void error() {
          Log log = Logging.getLog(JavascriptLogger.class);
          log.error("Javascript error: #0 from URL #1 at Line #2", message, url, lineNumber);