6 Replies Latest reply on Jan 23, 2009 9:28 AM by div garg

    JBoss Logging

    div garg Newbie

      Hi

      Here i m working on JBoss 4.2.2 and eclipse Gynemade. I m instantiating
      a java file at the time when jboss configure log4j.xml. I had given its entry
      in log4j.xml. Now my problem is that file have to access the database which
      are bound to perticuler JNDI names. And JNDI service starts after the log4j
      configure. So a null pointer exception is coming at the time server configure
      log4j, due to that java file. Can Anyone help me here. I m sending the change in log4j.xml that exception detail

      <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
       <param name="File" value="${jboss.server.log.dir}/server.log"/>
       <param name="Append" value="false"/>
      
       <!-- Rollover at midnight each day -->
       <param name="DatePattern" value="'.'yyyy-MM-dd"/>
      
       <!-- Rollover at the top of each hour
       <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
       -->
      
       <layout class="org.apache.log4j.PatternLayout">
       <!-- The default pattern: Date Priority [Category] Message\n -->
       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
      
       <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
       <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
       -->
       </layout>
       </appender>
      <appender name ="FILE1" class="org.apache.log4j.FileAppender">
       <param name="File" value="${jboss.server.log.dir}/server1.log" />
       <param name="Append" value="false" />
       <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
      
       </layout>
       <filter class="com.propco.tools.mergemanager.profiles.Domfilter"/>
      
      
      

      [img]http://img223.imageshack.us/my.php?image=95972212vg1.png[/img]

      Please zoom in the image as the image is a little out of focus.
      Sorry for the inconvenience.

      Thanks
      Divya Garg

        • 1. Re: JBoss Logging
          jaikiran pai Master

          Since the app server first configures logging and at a later point of time does the jndi bindings, i don't think you will be able to lookup the object from JNDI when the log4j is being initialized.

          I guess, you could try packaging your own log4j.xml inside you application and then use your custom class in that xml file. This way, by the time your log4j.xml is loaded (when you application is deployed and accessed) the JNDI bindings will be done. You might want to see this post to understand how you can package the log4j.xml in your app http://www.jboss.com/index.html?module=bb&op=viewtopic&t=128979#4125416

          • 2. Re: JBoss Logging
            div garg Newbie

            Actually my problem is i have to filter the logs into different log files according
            to the different JNDI names(databases).Means different log message of different database(JNDI) logs to different files .Can i do it without making any log4j.xml file ,by making any change to binding.

            • 3. Re: JBoss Logging
              div garg Newbie

              Please help me it is urgent.

              • 4. Re: JBoss Logging
                div garg Newbie

                Hi

                I m a learner here. In my application there is four main files.
                Propcoejb.jar, Propcoejbha.jar, client.jar and propco.sar. Here how can i configure my own log4j.xml so that JBoss sever configure that after all the
                JNDI binding is done. Please help me.

                Thanks
                Divya Garg

                • 5. Re: JBoss Logging
                  div garg Newbie

                  Hi

                  There is not any ear file in my application so how can i configure my custom log4j.xml into my application.There is only jar and sar files.

                  Thanks
                  Divya garg

                  • 6. Re: JBoss Logging
                    div garg Newbie

                    Here i have some changes to Jboss-service.xml.


                    <!-- ==================================================================== -->
                     <!-- Log4j Initialization -->
                     <!-- ==================================================================== -->
                    
                    
                    
                     <mbean code="org.jboss.logging.Log4jService"
                     name="jboss.system:type=Log4jService,service=Logging"
                     xmbean-dd="resource:xmdesc/Log4jService-xmbean.xml">
                     <attribute name="ConfigurationURL">resource:d1jboss-log4j.xml</attribute>
                     <!-- Set the org.apache.log4j.helpers.LogLog.setQuiteMode. As of log4j1.2.8
                     this needs to be set to avoid a possible deadlock on exception at the
                     appender level. See bug#696819.
                     -->
                     <attribute name="Log4jQuietMode">true</attribute>
                     <!-- How frequently in seconds the ConfigurationURL is checked for changes -->
                     <attribute name="RefreshPeriod">60</attribute>
                     <depends>jboss:service=DataSourceBinding</depends>
                    </mbean>
                    



                    And on the console error is DataSourceBinding Serveice is
                    YETNOTINSTALLED

                    while this service is going already.

                    Where i m lacking