1 Reply Latest reply on May 10, 2010 11:24 AM by Zemian Deng

    SetFile (null,true) in jboss log4j

    Ruchi Agrawal Newbie

      Hi ,

       

      I am stuck up with a strange issue while using my own log4j.properties with jboss .

      I have deployed a web application by enabling log4j logging . My log4j.properties file

      in is WEB-INF/classed folder and jboss is able to read that but after reading the [file]

      property it always gives file not found exception though I have already create the file

      in respective location infact it gives the same error when I specify server.log absolute path .

      /*************log.properties*****************/

      # Debug log4j
      log4j.rootCategory=debug,ApplicationLogger
      log4j.debug=true 
      log4j.logger.src.ApplicationLogger=debug, ApplicationLogger

       

      log4j.appender.ApplicationLogger=org.apache.log4j.RollingFileAppender
      log4j.appender.ApplicationLogger.file="${jboss.server.log.dir}/test.log"
      log4j.appender.ApplicationLogger.append=true
      log4j.appender.ApplicationLogger.layout=org.apache.log4j.PatternLayout

      log4j.appender.ApplicationLogger.layout.ConversionPattern=%d{MM- dd @HH:mm:ss} %-5p(%13F:%L) %3x -%m%n

       

      The error thrown is :

      log4j: Parsing for [root] with value=[debug,ApplicationLogger].
      16:46:19,999 INFO  [STDOUT] log4j: Level token is [debug].
      16:46:19,999 INFO  [STDOUT] log4j: Category root set to DEBUG
      16:46:19,999 INFO  [STDOUT] log4j: Parsing appender named "ApplicationLogger".
      16:46:20,045 INFO  [STDOUT] log4j: Parsing layout options for "ApplicationLogger".
      16:46:20,061 INFO  [STDOUT] log4j: Setting property [conversionPattern] to [%d{MM- dd @HH:mm:ss} %-5p (%13F:%L) %3x -%m%n].
      16:46:20,061 INFO  [STDOUT] log4j: End of parsing for "ApplicationLogger".
      16:46:20,077 INFO  [STDOUT] log4j: Setting property [file] to ["logserver.log"].
      16:46:20,077 INFO  [STDOUT] log4j: Setting property [append] to [true].
      16:46:20,077 INFO  [STDOUT] log4j: setFile called: "E:\test\jboss-5.1.0.GA-jdk6\jboss-5.1.0.GA\server\default\log", true
      16:46:20,077 ERROR [STDERR] log4j:ERROR setFile(null,true) call failed.
      16:46:20,077 ERROR [STDERR] java.io.FileNotFoundException: "E:\test\jboss-5.1.0.GA-jdk6\jboss-5.1.0.GA\server\default\log" (The filename, directory name, or volume label syntax is incorrect)
      16:46:20,077 ERROR [STDERR]     at java.io.FileOutputStream.openAppend(Native Method)
      16:46:20,077 ERROR [STDERR]     at java.io.FileOutputStream.<init>(Unknown Source)
      16:46:20,077 ERROR [STDERR]     at java.io.FileOutputStream.<init>(Unknown Source)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:809)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:735)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:547)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:483)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
      16:46:20,077 ERROR [STDERR]     at org.apache.log4j.Logger.getLogger(Logger.java:104)
      16:46:20,077 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      16:46:20,077 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      16:46:20,092 ERROR [STDERR]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      16:46:20,092 ERROR [STDERR]     at java.lang.reflect.Method.invoke(Unknown Source)
      16:46:20,092 ERROR [STDERR]     at org.apache.commons.logging.impl.Log4jProxy.<init>(Log4jProxy.java:145)
      16:46:20,092 ERROR [STDERR]     at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:288)
      16:46:20,092 ERROR [STDERR]     at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:91)
      16:46:20,092 ERROR [STDERR]     at sun.reflect.GeneratedConstructorAccessor141.newInstance(Unknown Source)
      16:46:20,092 ERROR [STDERR]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      16:46:20,092 ERROR [STDERR]     at java.lang.reflect.Constructor.newInstance(Unknown Source)
      16:46:20,092 ERROR [STDERR]     at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1040)
      16:46:20,092 ERROR [STDERR]     at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:782)
      16:46:20,092 ERROR [STDERR]     at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:601)
      16:46:20,092 ERROR [STDERR]     at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:333)
      16:46:20,092 ERROR [STDERR]     at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:307)
      16:46:20,092 ERROR [STDERR]     at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:645)
      16:46:20,092 ERROR [STDERR]     at src.ApplicationLogger.getLogger(ApplicationLogger.java:10)
      16:46:20,092 ERROR [STDERR]     at src.Usersweb.<clinit>(Usersweb.java:25)
      16:46:20,092 ERROR [STDERR]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      16:46:20,092 ERROR [STDERR]     at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      16:46:20,092 ERROR [STDERR]     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      16:46:20,092 ERROR [STDERR]     at java.lang.reflect.Constructor.newInstance(Unknown Source)
      16:46:20,092 ERROR [STDERR]     at java.lang.Class.newInstance0(Unknown Source)
      16:46:20,092 ERROR [STDERR]     at java.lang.Class.newInstance(Unknown Source)
      16:46:20,092 ERROR [STDERR]     at org.jboss.web.tomcat.service.TomcatInjectionContainer.newInstance(TomcatInjectionContainer.java:264)
      16:46:20,092 ERROR [STDERR]     at org.jboss.web.tomcat.service.TomcatInjectionContainer.newInstance(TomcatInjectionContainer.java:256)
      16:46:20,092 ERROR [STDERR]     at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1006)
      16:46:20,092 ERROR [STDERR]     at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:777)
      16:46:20,092 ERROR [STDERR]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
      16:46:20,092 ERROR [STDERR]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      16:46:20,092 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
      16:46:20,092 ERROR [STDERR]     at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
      16:46:20,092 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      16:46:20,092 ERROR [STDERR]     at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      16:46:20,092 ERROR [STDERR]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      16:46:20,092 ERROR [STDERR]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      16:46:20,092 ERROR [STDERR]     at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      16:46:20,092 ERROR [STDERR]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      16:46:20,092 ERROR [STDERR]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      16:46:20,092 ERROR [STDERR]     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      16:46:20,092 ERROR [STDERR]     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
      16:46:20,092 ERROR [STDERR]     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      16:46:20,092 ERROR [STDERR]     at java.lang.Thread.run(Unknown Source)

        • 1. Re: SetFile (null,true) in jboss log4j
          Zemian Deng Apprentice

          That's because you added quotes to your log filename in your log4j.properties file!

           

          This

          log4j.appender.ApplicationLogger.file="${jboss.server.log.dir}/test.log"

          should be without quotes:

          log4j.appender.ApplicationLogger.file=${jboss.server.log.dir}/test.log

           

           

          Also, this line looks funny, and it probably incorrect:

          log4j.logger.src.ApplicationLogger=debug, ApplicationLogger

          You probably wantted to have your application package name like:

          log4j.logger.myapplication.pkg.name=debug, ApplicationLogger

           

          And I would recommend you rename ApplicationLogger to FILE_APPENDER to be less confusing.

           

          And final note, all these have nothing to do with jboss. Consult log4j docs for more details.