8 Replies Latest reply on Dec 16, 2011 1:00 PM by norad_2

    JMS appender in JBoss AS 7

    norad_2

      I am trying to upgrade an application from JBoss 4.x to JBoss 7.

       

      In JBoss 4, a JMS appender was defined in jboss/server/<instance>/conf/log4j.xml

       

      {code:xml}

      <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

        ...

        <appender name="JMS" class="org.apache.log4j.net.JMSAppender">

          <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>

          <param name="Threshold" value="DEBUG"/>

          <param name="InitialContextFactoryName" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>

          <param name="ProviderURL" value="tcp://localhost:61616"/>

          <param name="TopicBindingName" value="topics/logTopic"/>

          <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>

        </appender>

        ...

        <root>

          ...

          <appender-ref ref="JMS"/>

        </root>

      </log4j:configuration>

      {code}

       

      I found some posts where people tried to do this in Jboss AS 6 by changing it to something like this:

       

       

      {code:xml}

      <log4j-appender name="JMS" class="org.apache.log4j.net.JMSAppender">

        <error-manager>

          <only-once/>

        </error-manager>

       

        <level name="DEBUG" />

       

        <properties>

          <property name="topicConnectionFactoryBindingName">ConnectionFactory</property>

          <property name="topicBindingName">topics/logTopic</property>

        </properties>

      </log4j-appender>

      {code}

       

      However based on what I've read in the linked article below, it sounds like other than the provided handlers (console, file, async), any others have to be re-written as a custom handler that implements java.util.logging.Handler. Looking at org.apache.log4j.net.JMSAppender, it doesn't seem like it implements this so it wouldn't be able to just plugin nicely.

       

      http://community.jboss.org/wiki/CustomLogHandlersOn701

       

      Can the apache JMSAppender still be used as a handler in JBoss AS 7 or does it need to be re-written?

        • 1. Re: JMS appender in JBoss AS 7
          jaikiran

          I think you'll have to implement a custom handler until this http://community.jboss.org/message/641359#641359 is available.

          • 2. Re: JMS appender in JBoss AS 7
            nickarls

            When I was tinkering along with a datasource-backed DB-logger there were some issues with JNDI lookup because JNDI was not exported or something (and any workaround where not guaranteed to be supported in the future), would JNDI lookup for JMS (in this case) or the mail session for a mail appender face similar things?

            • 3. Re: JMS appender in JBoss AS 7
              jaikiran

              Nicklas Karlsson wrote:

               

              would JNDI lookup for JMS (in this case) or the mail session for a mail appender face similar things?

              Yes

              • 4. Re: JMS appender in JBoss AS 7
                nickarls

                Are all modules forever doomed to be "outsiders" in this respect or has there been any thought of "AS modules" that could use JNDI lookup?

                • 5. Re: JMS appender in JBoss AS 7
                  jaikiran

                  Nicklas Karlsson wrote:

                   

                  or has there been any thought of "AS modules" that could use JNDI lookup?

                  It's just a matter of setting up the correct service dependencies while booting those appenders/handlers in the logging subsystem. Each handler might depend on a different (type of) service. But I think it should be doable atleast for some of the common usecases. From what I know, it hasn't yet been on priority because of other work that's going on in logging currently. But James and David would know if there's more to this than just setting up the correct dependencies.

                  • 6. Re: JMS appender in JBoss AS 7
                    jaikiran

                    By the way, this isn't something specific to AS7. I believe the previous AS versions too had similar issues where the JMS queue or the datasource had to be available in the JNDI before these appenders defined the JBOSS_HOME/conf/jboss-log4j.xml could be started. I don't remember how that was solved (if at all) there.

                    • 7. Re: JMS appender in JBoss AS 7
                      nickarls

                      I used lazy initialization for my appender so logging requests that came in before the lookup was successful were just silently dropped.

                      • 8. Re: JMS appender in JBoss AS 7
                        norad_2

                        jaikiran pai wrote:

                         

                        By the way, this isn't something specific to AS7. I believe the previous AS versions too had similar issues where the JMS queue or the datasource had to be available in the JNDI before these appenders defined the JBOSS_HOME/conf/jboss-log4j.xml could be started. I don't remember how that was solved (if at all) there.

                         

                        In JBoss 4.x you would add the topic/queue to the jndi.properties file in the jboss/server/<instance>/conf directory.

                         

                        Datasource files were just dropped in the deploy directory and added to the jndi automatically.