5 Replies Latest reply on Oct 15, 2013 3:54 PM by jamezp

    why is logging not showing in the log file when method is called from a xhtml page?

    bhoman

      background:

      I have a method that returns a list.  the method getNexusMembers()

       

      @Name("nexus.functionManager.manageFunction")

      @Scope(ScopeType.CONVERSATION)

      public class ManageFunctionAction implements Serializable {

      ...

      public List<NexusMember> getNexusMembers() {
        log.debug("getNexusMembers");
        System.out.println("getNexusMembers");
        Query query = nexusDatabase.createQuery("SELECT m FROM NexusMember m ORDER BY m.memberId");
        return query.getResultList();

          }

      }

       

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"

          xmlns:s="http://jboss.org/schema/seam/taglib"

          xmlns:ui="http://java.sun.com/jsf/facelets"

          xmlns:f="http://java.sun.com/jsf/core"

          xmlns:h="http://java.sun.com/jsf/html"

          xmlns:rich="http://richfaces.org/rich"

          template="/layout/template.xhtml">

       

          <ui:define name="body">

              <h1 id="pageHeader">

                  <h:outputText

                      value="#{nexus.functionManager.manageFunction.pageHeader}" />

              </h1>

       

              <h:form id="functionForm">

      ...

      <s:selectItems value="#{myClass.nexusMembers}" var="member" label="#{member.memberId}" noSelectionLabel="" />

      ...

          </h:form>

          </ui:define>

      </ui:composition>

       

       

       

      The situation and question:

       

      My understanding is that inside the s:selectItems the value:myClass.nexusMembers  calls the method getNexusMembers.  This call works; my page has data loaded.  My problem is that when I added a log.debug ( the logging level was set accordingly) or even when I used System.out.println(...) these statements never showed in the server.log (nor in the console).

       

      When I added a line of code to call this method from within the same class, but not from the xhtml, the log statement was displayed in server.log and on the console.

       

      Can someone help me understand why this is so?

       

      thank you

        • 1. Re: why is logging not showing in the log file when method is called from a xhtml page?
          jamezp

          What logging facade are you using?

           

          --

          James R. Perkins

          • 2. Re: why is logging not showing in the log file when method is called from a xhtml page?
            bhoman

            I am using log4j.

             

            import org.jboss.seam.log.Log;

            import org.jboss.seam.annotations.Logger;

            ...

            @Logger

                private Log log;

            ...

            public List<NexusMember> getNexusMembers() {

                    log.debug("getNexusMembers");

                    System.out.println("getNexusMembers");

                    Query query = nexusDatabase.createQuery("SELECT m FROM NexusMember m ORDER BY m.memberId");

                    return query.getResultList();

            }

             

            when I call this method from another Java method the logs are written.  when I call this from xhtml (snippet follows) no logs are created

             

            <s:decorate id="memberField" template="/layout/edit.xhtml">

                <ui:define name="label">Nexus Member</ui:define>

                <h:selectOneMenu id="member" required="true" value="#{currentFunction.nexusMember}">

                    <s:selectItems value="#{nexus.functionManager.manageFunction.nexusMembers}" var="member" label="#{member.memberId}" noSelectionLabel="" />

                    <f:converter converterId="nexusEntityConverter" />

                </h:selectOneMenu>

            </s:decorate>

            • 3. Re: why is logging not showing in the log file when method is called from a xhtml page?
              jamezp

              That seems weird. Do you by chance have a log4j configuration file in your deployment?

               

              --

              James R. Perkins

              • 4. Re: why is logging not showing in the log file when method is called from a xhtml page?
                bhoman

                yes I do.

                it is a log4j.xml file under the project/src directory, along with a log4j.dtd

                 

                <?xml version="1.0" encoding="UTF-8" ?>

                <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

                 

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

                    <!-- Appenders -->

                    <appender name="NEXUS_C-SYSOUT" class="org.apache.log4j.ConsoleAppender">

                        <param name="Target" value="System.out" />

                        <layout class="org.apache.log4j.PatternLayout">

                            <param name="ConversionPattern" value="Nexus Core      [%-10X{username}] [%-15X{clientip}] %c{3} - %m%n" />

                        </layout>

                    </appender>

                    <appender name="NEXUS_C-SYSOUT-MFCOMM" class="org.apache.log4j.ConsoleAppender">

                        <param name="Target" value="System.out" />

                        <layout class="org.apache.log4j.PatternLayout">

                            <param name="ConversionPattern" value="Nexus Core      [%-10X{username}] [%-15X{clientip}] %c{3} GI Service Call Log: %X{serviceName} - Auth Info='%X{appName}' - '%X{targetUrl}' - %X{elapsedTime} ms %m%n" />

                        </layout>

                    </appender>

                 

                    <!-- Loggers -->

                    <logger name="edu.psu" additivity="false">

                        <level value="DEBUG" />

                        <appender-ref ref="NEXUS_C-SYSOUT" />

                    </logger>

                    <logger name="edu.psu.nexus.gi" additivity="false">

                        <level value="DEBUG" />

                        <appender-ref ref="NEXUS_C-SYSOUT-MFCOMM" />

                    </logger>

                    <logger name="org.jboss.seam" additivity="false">

                        <level value="DEBUG" />

                        <appender-ref ref="NEXUS_C-SYSOUT" />

                    </logger>

                    <root>

                        <priority value="OFF" />

                        <appender-ref ref="NEXUS_C-SYSOUT" />

                    </root>

                </log4j:configuration>

                • 5. Re: why is logging not showing in the log file when method is called from a xhtml page?
                  jamezp

                  If you're using a build off a 7.1.2+ tag or JBoss EAP 6.x then it's likely picking up that configuration file and configuring logging. You have the root priority set to OFF so if System.out.printx() definitely won't show up. The logger may or may not based on the package name.

                   

                  The first thing to try is to pass -Dorg.jboss.as.logging.per-deployment=false or remove the log4j.xml file from your deployment. Also make sure you're not including a log4j library in your deployment either.

                   

                  --

                  James R. Perkins