4 Replies Latest reply on May 10, 2009 2:22 PM by Amit Phatarphekar

    Log4j error inn jboss

    Ravi Singh Newbie

      Hello,

      i am using commons-logging.jar, log4j-1.2.12.jar and i have drop my lo4j.properties file in my web application's WEB-INF/classes folder . when i start the server i got this error.
      i want to do logging for my web application in a seprate log file which is in my application WEB-INF folder WEB-INF/myapp.log

      this is server console error



      20:45:13,984 ERROR [STDERR] log4j:ERROR A "org.jboss.logging.util.OnlyOnceErrorHandler" object is not assignable to a "org.apache.log4j.spi.ErrorHandler" variable.
      20:45:13,984 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.spi.ErrorHandler" was loaded by
      20:45:13,984 ERROR [STDERR] log4j:ERROR [WebappClassLoader
      delegate: false
      repositories:
      /WEB-INF/classes/
      ----------> Parent Classloader:
      java.net.FactoryURLClassLoader@f23491
      ] whereas object of type
      20:45:13,984 ERROR [STDERR] log4j:ERROR "org.jboss.logging.util.OnlyOnceErrorHandler" was loaded by [org.jboss.system.server.NoAnnotationURLClassLoader@1833955].
      20:45:14,031 ERROR [STDERR] log4j:ERROR Could not create an Appender. Reported error follows.
      20:45:14,031 ERROR [STDERR] java.lang.ClassCastException: org.jboss.logging.appender.DailyRollingFileAppender
      20:45:14,031 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:175)
      20:45:14,031 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:150)
      20:45:14,031 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:163)
      20:45:14,031 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:425)
      20:45:14,031 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:394)
      20:45:14,031 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:829)
      20:45:14,031 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:712)
      20:45:14,031 ERROR [STDERR] at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:618)
      20:45:14,031 ERROR [STDERR] at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:468)
      20:45:14,031 ERROR [STDERR] at org.apache.log4j.LogManager.(LogManager.java:122)
      20:45:14,031 ERROR [STDERR] at org.apache.log4j.Logger.getLogger(Logger.java:104)
      20:45:14,031 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      20:45:14,031 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      20:45:14,031 E





      Please help me how can i maintain logging in my application.

      Thanks in advance
      Ravi adha






        • 1. Re: Log4j error inn jboss
          rong bin Newbie

          hello.
          the problem have some reason.
          i).if your aplication lib have the log4j.jar,del it.
          ii).your aplication use the log4j.properties, it's unusefull. you must instead a log4j.xml.
          you can get the file in Jboss's conf/log4j.xml, you can put a copy to your aplication path.

          that's all.

          • 2. Re: Log4j error inn jboss
            Larry Wilson Newbie

            I'm having exactly the same issue:

            09:53:59,242 ERROR [STDERR] log4j:ERROR A "org.jboss.logging.util.OnlyOnceErrorHandler" object is not assignable to a "org.apache.log4j.spi.ErrorHandler" variable.
            09:53:59,243 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.spi.ErrorHandler" was loaded by
            09:53:59,244 ERROR [STDERR] log4j:ERROR [WebappClassLoader
             delegate: false
             repositories:
             /WEB-INF/classes/
            ----------> Parent Classloader:
            java.net.FactoryURLClassLoader@df6322
            ] whereas object of type
            09:53:59,245 ERROR [STDERR] log4j:ERROR "org.jboss.logging.util.OnlyOnceErrorHandler" was loaded by [org.jboss.system.server.NoAnnotationURLClassLoader@7471e0].
            09:53:59,723 ERROR [STDERR] log4j:ERROR Could not create an Appender. Reported error follows.
            09:53:59,724 ERROR [STDERR] java.lang.ClassCastException: org.jboss.logging.appender.DailyRollingFileAppender
            


            However, if I remove Log4J from my build path, the application won't compile. I've tried several versions of Log4J, just in case, with no change in behavior. Been using JBoss for years, but with 4.0.5GA I'm having this problem with my applications.

            I've tried everything I can think of.

            Running:
            MacOSX 10.4.8
            Java 1.5_06
            MyEclipseIDE 5.1.0GA
            Eclipse 3.2.1

            Any ideas?



            • 3. Re: Log4j error inn jboss
              Kurt Olsen Newbie

              The objective would be to ensure that the log4.jar in your WEB-INF/lib is NOT there when you deploy to jboss, even though it is in your build path.
              Ant perhaps?

              • 4. Re: Log4j error inn jboss
                Amit Phatarphekar Newbie

                My own logs used to get created when I had my log4j.jar and commons-logging in my WEB-INF/lib folder, but I used to get the "OnlyOnceErrorHandler" exception. So in order to eliminate this exception i removed the log4j and commons-logging from my WEB-INF/lib folder. I dont get any exception anymore. But now, my logs dont get created anywhere- not even in server.log