Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problems with log4j

    I have problems using log4j with smartgwt in the server logs. I know that this is not a problem directly related to smartGWT, but maybe you know a solution for this ? I have tried a lot, but nothing seems to work.

    I have the default log4j.isc.config.xml :
    Code:
    	
    
        <?xml version="1.0" encoding="UTF-8" ?>
        <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
         
        <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
         
                <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
                        <layout class="org.apache.log4j.PatternLayout">
                           <param name="ConversionPattern"
                                          value="=== %d [%.4t] %-5p %c{1} - %m%n"/>
                        </layout>              
                </appender>
         
                <appender name="FILE_LOG" class="org.apache.log4j.FileAppender">
                    <param name="File"   value="/smartClientServerLog.txt" />
                    <param name="Append" value="false" />              
                    <layout class="org.apache.log4j.PatternLayout">
                        <param name="ConversionPattern" value="=== %d [%.4t] %-5p %c{1} - %m%n"/>
                    </layout>      
                </appender>
         
            <!-- This appender is used by the "Server Logs" tab in the Developer Console. -->
                <appender name="SmartClientLog" class="com.isomorphic.log.RevolvingMemoryAppender">
                    <param name="maxEntries" value="500"/>
                <layout class="org.apache.log4j.PatternLayout">
                           <param name="ConversionPattern"
                                          value="=== %d [%.4t] %-5p %c{1} - %m%n"/>
                        </layout>      
                </appender>
         
            <!-- isomorphic log messages -->
            <!-- The STDOUT appender defined above is set as the default appender for all Isomorphic
                SmartClient server logging.  It should typically be visible in the console from which
                you started the application server.
               
                Some Application Servers redirect stdout output to a file (typically called stdout.log
                or something like that, so you should be able to find it there.
         
                If you can't find the server log, you should be able to use the SmartClientLog (above)
                which is visible in the Developer Console under "Server Logs" and as a standalone log
                viewer in /tools/serverLogViewer.jsp.  
               
                Failing all of the above, you can switch the appender-ref value for the com.isomorphic
                category to use the FILE_LOG appender which will log to /smartClientServerLog.txt on
                UNIX and C:\smartClientServerLog.txt on Windows.  You can change this by modifying the
                value of the "File" param in the FILE_LOG definition above.
           -->
                <category name="com.isomorphic">
                  <priority value="DEBUG" />
              <appender-ref ref="STDOUT"/>
              <appender-ref ref="SmartClientLog"/>
                </category>
         
                <category name="com.isomorphic.base.Reflection">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.base.ISCInit">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.base.ConfigLoader">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.download.Download">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.sql.ValueSet">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.servlet.RequestContext">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.datasource.DataSource">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.datasource.BasicDataSource">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.datasource.AuditDSGenerator">
                    <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.validation.Validation">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.store.DataStructCache">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.assembly.FileAssembler">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.obfuscation.Obfuscator">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.servlet.PreCache">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.timing.Timing">
                  <priority value="INFO" />
                </category>
           
                <category name="com.isomorphic.resultData.ResultData">
              <priority value="INFO" />
            </category>
         
            <category name="com.isomorphic.js.JSSyntaxScannerFilter">
                <priority value="INFO" />
            </category>
         
                <category name="com.isomorphic.interfaces.InterfaceProvider">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.compression.Compression">
                  <priority value="INFO" />
                </category>
         
                <category name="com.isomorphic.servlet.ProxyHttpServletResponse">
                  <priority value="INFO" />
                </category>
         
            <category name="com.isomorphic.naming.JNDI">
              <priority value="WARN" />
            </category>
               
                <category name="com.isomorphic.scripting">
                  <priority value="INFO" />
                </category>
         
                <category name="org.apache.velocity">
                  <priority value="WARN" />
                </category>
         
                <category name="org.hibernate.SQL">
                  <priority value="DEBUG" />
                </category>
         
            <!-- shows values bound to params in SQL query, but produces a lot of output -->
            <!--
                <category name="org.hibernate.type">
                  <priority value="DEBUG" />
             <appender-ref ref="STDOUT"/>
                </category>
           -->
         
                <!-- embedded tomcat -->
                <category name="org.apache">
                  <priority value="INFO" />
              <appender-ref ref="STDOUT"/>
              <appender-ref ref="SmartClientLog"/>
                </category>
         
            <!-- hibernate log messages -->
                <category name="org.hibernate">
                  <priority value="DEBUG" />
              <appender-ref ref="STDOUT"/>
              <appender-ref ref="SmartClientLog"/>
                </category>
               
               
                <!-- Custom server log messages -->
               
        </log4j:configuration>
    All smartGWT logs are showing correctly, so this seems to be correctly configured.

    If I try to add a customer logger, I add the following to the configuration:
    Code:
    <!-- Custom server log messages -->
                <category name="de.mycompany.myapp">
                        <priority value="DEBUG" />
                        <appender-ref ref="STDOUT"/>
                        <appender-ref ref="SmartClientLog"/>
                </category>
    My application code:


    I add this to de.mycompany.myapp.server.dmi.SessionDMIHandler:
    Code:
    private static final Logger LOG = Logger.getLogger(SessionDMIHandler.class);
    
    ...
    
    LOG.error("Session log: error");
    	LOG.warn("Session log: warn");
    	LOG.debug("Session log: debug");
    	LOG.info("Session log: info");
    I see ONLY the following in the tomcat8-stdout.2014-10-02 created by apache 8.0.9 :
    Code:
    ERROR [SessionDMIHandler] - Session log: error 
    WARN [SessionDMIHandler] - Session log: warn
    So I only see error and warn logs. But I don't see any info or debug logs, although my configuration level is debug. What am I doing wrong?

    The ERROR and WARN logs shown are also not formatted as the rest of SmartGWT logs (e.g. they don't include the timestamp).

    Do you have an idea what I may be doing wrong?

    Using smartgwt 4.1p with log4j-1.2.15.jar (included with smartgwt).
    Last edited by edulid; 2 Oct 2014, 06:18.

    #2
    Both behaviors you're seeing (not using the PatternLayouts we define, and suppressing debug/info logs) suggest that your configuration is not being read at all.

    So we'd suggest triple-checking that the log4j file you're modifying is the actual one that your servlet engine is loading. One quick way to do this would be to modify the log level for one of the built-in log categories and make sure that is taking effect.

    Comment


      #3
      Thank you for your quick response.

      I checked this by replacing all "info"s with "debug"s in my config file, and my tomcat8-stdout.2014-10-02.log is now 2494 kb (in contrast to 175 kb), so I think the file is being read :-)

      I am not saying that *all* logs are not using the PatternLayouts, but *my application logs*:
      an example of my logfile:

      Code:
      ERROR [SessionDMIHandler] - Session log: error 
      WARN [SessionDMIHandler] - Session log: warn 
      === 2014-10-02 16:56:58,610 [ec-8] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
      === 2014-10-02 16:56:58,610 [ec-8] DEBUG DeclarativeSecurity - DataSource users is not in the pre-checked list, processing...
      So I only see unformatted ERRORs and WARNs for my application logs, while the rest of the logs are formated.
      Example:
      Code:
      === 2014-10-02 16:56:50,123 [op-1] DEBUG DataStructCache - getInstanceFile (failure): 'float' instance of datasources: 0ms
      === 2014-10-02 16:56:50,124 [op-1] DEBUG DataStructCache - getInstanceFile (failure): 'float' instance of datasources: 1ms
      === 2014-10-02 16:56:50,124 [op-1] DEBUG Validation - Value provided for unknown field: Object.validators: value is: isFloat
      And, as you see:
      Code:
      ERROR [SessionDMIHandler] - Session log: error 
      WARN [SessionDMIHandler] - Session log: warn
      I can only see EERORS and WARNs (unformatted), although I have more logs:
      Code:
      LOG.error("Session log: error");
      	LOG.warn("Session log: warn");
      	LOG.debug("Session log: debug");
      	LOG.info("Session log: info");
      So where are the other logs? The level is DEBUG, so I should be seeing DEBUG and INFO too.

      If this is any help, the logs from my logger until SmartGWT is initializing:
      Code:
      2014-10-02 17:16:51 Commons Daemon procrun stdout initialized
      ISC: Configuring log4j from: file:/C:/Users/Eduardo/git/zedes2/zedes2/war/WEB-INF/classes/log4j.isc.config.xml
      log4j: reset attribute= "false".
      log4j: Threshold ="null".
      log4j: Retreiving an instance of org.apache.log4j.Logger.
      log4j: Setting [com.isomorphic] additivity to [true].
      log4j: Level value for com.isomorphic is  [DEBUG].
      log4j: com.isomorphic level set to DEBUG
      log4j: Class name: [org.apache.log4j.ConsoleAppender]
      log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
      log4j: Setting property [conversionPattern] to [=== %d [%.4t] %-5p %c{1} - %m%n].
      log4j: Adding appender named [STDOUT] to category [com.isomorphic].
      log4j: Class name: [com.isomorphic.log.RevolvingMemoryAppender]
      log4j: Setting property [maxEntries] to [500].
      log4j: Parsing layout of class: "org.apache.log4j.PatternLayout"
      log4j: Setting property [conversionPattern] to [=== %d [%.4t] %-5p %c{1} - %m%n].
      log4j: Adding appender named [SmartClientLog] to category [com.isomorphic].
      log4j: Retreiving an instance of org.apache.log4j.Logger.
      log4j: Setting [org.apache] additivity to [true].
      log4j: Level value for org.apache is  [INFO].
      log4j: org.apache level set to INFO
      log4j: Adding appender named [STDOUT] to category [org.apache].
      log4j: Adding appender named [SmartClientLog] to category [org.apache].
      log4j: Retreiving an instance of org.apache.log4j.Logger.
      log4j: Setting [org.hibernate] additivity to [true].
      log4j: Level value for org.hibernate is  [DEBUG].
      log4j: org.hibernate level set to DEBUG
      log4j: Adding appender named [STDOUT] to category [org.hibernate].
      log4j: Adding appender named [SmartClientLog] to category [org.hibernate].
      log4j: Retreiving an instance of org.apache.log4j.Logger.
      log4j: Setting [de.mks_infofabrik.zedes2] additivity to [true].
      log4j: Level value for de.mks_infofabrik.zedes2 is  [DEBUG].
      log4j: de.mks_infofabrik.zedes2 level set to DEBUG
      log4j: Adding appender named [STDOUT] to category [de.mks_infofabrik.zedes2].
      log4j: Adding appender named [SmartClientLog] to category [de.mks_infofabrik.zedes2].
      log4j: Retreiving an instance of org.apache.log4j.Logger.
      log4j: Setting [de.mks_infofabrik.zedes2.server] additivity to [true].
      log4j: Level value for de.mks_infofabrik.zedes2.server is  [DEBUG].
      log4j: de.mks_infofabrik.zedes2.server level set to DEBUG
      log4j: Retreiving an instance of org.apache.log4j.Logger.
      log4j: Setting [de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler] additivity to [true].
      log4j: Level value for de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler is  [DEBUG].
      log4j: de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler level set to DEBUG
      log4j: Adding appender named [STDOUT] to category [de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler].
      log4j: Adding appender named [SmartClientLog] to category [de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler].
      log4j: Trying to find [log4j.isc.project.config.xml] using context classloader WebappClassLoader
        context: /zedes2
        delegate: false
      ----------> Parent Classloader:
      java.net.URLClassLoader@1d926e41
      .
      log4j: Trying to find [log4j.isc.project.config.xml] using WebappClassLoader
        context: /zedes2
        delegate: false
      ----------> Parent Classloader:
      java.net.URLClassLoader@1d926e41
       class loader.
      log4j: Trying to find [log4j.isc.project.config.xml] using ClassLoader.getSystemResource().
      === 2014-10-02 17:17:11,271 [op-1] INFO  ISCInit - Isomorphic SmartClient/SmartGWT Framework - Initializing
      (Edit: I replaced the logger logs , since they had an error) .
      Last edited by edulid; 2 Oct 2014, 07:19.

      Comment


        #4
        Seems to load correctly:

        Code:
        log4j: Level value for de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler is  [DEBUG].
        log4j: de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler level set to DEBUG
        log4j: Adding appender named [STDOUT] to category [de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler].
        log4j: Adding appender named [SmartClientLog] to category [de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler].
        But WHERE ARE these logs with category DEBUG? I don't find them! I only see these 2 unformatted logs:
        Code:
        === 2014-10-02 17:17:20,698 [ec-1] DEBUG Reflection - method takes: 4 args.  I've assembled: 4 args
        === 2014-10-02 17:17:20,698 [ec-1] DEBUG Reflection - invoking method:
        com.isomorphic.datasource.DSResponse de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler.fetchCurrentUserInfo(com.isomorphic.datasource.DSRequest, com.isomorphic.rpc.RPCManager, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpSession) throws java.lang.Exception
        
        with arg types: com.isomorphic.datasource.DSRequest, com.isomorphic.rpc.RPCManager, com.isomorphic.servlet.ISCHttpServletRequest, org.apache.catalina.session.StandardSessionFacade
        ERROR [SessionDMIHandler] - Session log: error 
        WARN [SessionDMIHandler] - Session log: warn 
        === 2014-10-02 17:17:20,699 [ec-1] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
        Really strange :-/

        Maybe the problem is here?
        Code:
        log4j: Trying to find [log4j.isc.project.config.xml] using context classloader WebappClassLoader
          context: /zedes2
          delegate: false
        ----------> Parent Classloader:
        java.net.URLClassLoader@1d926e41
        .
        log4j: Trying to find [log4j.isc.project.config.xml] using WebappClassLoader
          context: /zedes2
          delegate: false
        ----------> Parent Classloader:
        java.net.URLClassLoader@1d926e41
         class loader.
        log4j: Trying to find [log4j.isc.project.config.xml] using ClassLoader.getSystemResource().
        What is happening here? I don't have any file log4j.isc.project.config.xml, only the log4j.isc.config.xml file
        Last edited by edulid; 2 Oct 2014, 07:31.

        Comment


          #5
          Wow, this is interesting:

          if I rename my file log4j.isc.config.xml to log4j.xml, my logs are being printed and formatted, but 2 times! And ALL isomorphic logs are gone!!! This is strange

          Code:
          log4j: Retreiving an instance of org.apache.log4j.Logger.
          log4j: Setting [de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler] additivity to [true].
          log4j: Level value for de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler is  [DEBUG].
          log4j: de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler level set to DEBUG
          log4j: Adding appender named [STDOUT] to category [de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler].
          log4j: Adding appender named [SmartClientLog] to category [de.mks_infofabrik.zedes2.server.dmi.SessionDMIHandler].
          === 2014-10-02 17:34:38,964 [ec-1] ERROR SessionDMIHandler - Session log: error
          === 2014-10-02 17:34:38,964 [ec-1] ERROR SessionDMIHandler - Session log: error
          === 2014-10-02 17:34:38,967 [ec-1] WARN  SessionDMIHandler - Session log: warn
          === 2014-10-02 17:34:38,967 [ec-1] WARN  SessionDMIHandler - Session log: warn
          === 2014-10-02 17:34:38,967 [ec-1] DEBUG SessionDMIHandler - Session log: debug
          === 2014-10-02 17:34:38,967 [ec-1] DEBUG SessionDMIHandler - Session log: debug
          === 2014-10-02 17:34:38,967 [ec-1] INFO  SessionDMIHandler - Session log: info
          === 2014-10-02 17:34:38,967 [ec-1] INFO  SessionDMIHandler - Session log: info
          So this means I have to have BOTH config files? one for isomorphic logs and one for my project stuff ? And why do I see the logs 2 times?

          Comment


            #6
            In a nutshell, Log4j is capable of running with several concurrent configurations that can be separately accessed.

            Your approach of Logger.getLogger() is retrieving a Logger which has not been configured by log4.isc.config.xml. That's why it has no patterns in its output and isn't logging at DEBUG level.

            When you then add log4j.xml you've created a whole separate configuration that is parallel to the one created by log4.isc.config.xml, so you see dupes.

            Stay tuned, we're looking for the best way for you to get a Logger that has been configured by log4j.isc.config.xml.

            Another alternative is of course to add a log4j.xml that is similar to log4j.isc.config.xml, but squelches all SmartGWT log output.

            Comment


              #7
              Thanks for your explanation. After trying different variants, I found out that, until now, the best configuration is having indeed 2 files:

              log4j.isc.config.xml
              Code:
              <?xml version="1.0" encoding="UTF-8" ?>
                  <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
                   
                  <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
                   
                          <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
                                  <layout class="org.apache.log4j.PatternLayout">
                                     <param name="ConversionPattern"
                                                    value="=== %d [%.4t] %-5p %c{1} - %m%n"/>
                                  </layout>              
                          </appender>
                   
                          <appender name="FILE_LOG" class="org.apache.log4j.FileAppender">
                              <param name="File"   value="/smartClientServerLog.txt" />
                              <param name="Append" value="false" />              
                              <layout class="org.apache.log4j.PatternLayout">
                                  <param name="ConversionPattern" value="=== %d [%.4t] %-5p %c{1} - %m%n"/>
                              </layout>      
                          </appender>
                   
                      <!-- This appender is used by the "Server Logs" tab in the Developer Console. -->
                          <appender name="SmartClientLog" class="com.isomorphic.log.RevolvingMemoryAppender">
                              <param name="maxEntries" value="500"/>
                          <layout class="org.apache.log4j.PatternLayout">
                                     <param name="ConversionPattern"
                                                    value="=== %d [%.4t] %-5p %c{1} - %m%n"/>
                                  </layout>      
                          </appender>
                   
                      <!-- isomorphic log messages -->
                      <!-- The STDOUT appender defined above is set as the default appender for all Isomorphic
                          SmartClient server logging.  It should typically be visible in the console from which
                          you started the application server.
                         
                          Some Application Servers redirect stdout output to a file (typically called stdout.log
                          or something like that, so you should be able to find it there.
                   
                          If you can't find the server log, you should be able to use the SmartClientLog (above)
                          which is visible in the Developer Console under "Server Logs" and as a standalone log
                          viewer in /tools/serverLogViewer.jsp.  
                         
                          Failing all of the above, you can switch the appender-ref value for the com.isomorphic
                          category to use the FILE_LOG appender which will log to /smartClientServerLog.txt on
                          UNIX and C:\smartClientServerLog.txt on Windows.  You can change this by modifying the
                          value of the "File" param in the FILE_LOG definition above.
                     -->
                          <category name="com.isomorphic">
                            <priority value="DEBUG" />
                        <appender-ref ref="STDOUT"/>
                        <appender-ref ref="SmartClientLog"/>
                          </category>
                   
                          <category name="com.isomorphic.base.Reflection">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.base.ISCInit">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.base.ConfigLoader">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.download.Download">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.sql.ValueSet">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.servlet.RequestContext">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.datasource.DataSource">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.datasource.BasicDataSource">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.datasource.AuditDSGenerator">
                              <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.validation.Validation">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.store.DataStructCache">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.assembly.FileAssembler">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.obfuscation.Obfuscator">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.servlet.PreCache">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.timing.Timing">
                            <priority value="INFO" />
                          </category>
                     
                          <category name="com.isomorphic.resultData.ResultData">
                        <priority value="INFO" />
                      </category>
                   
                      <category name="com.isomorphic.js.JSSyntaxScannerFilter">
                          <priority value="INFO" />
                      </category>
                   
                          <category name="com.isomorphic.interfaces.InterfaceProvider">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.compression.Compression">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="com.isomorphic.servlet.ProxyHttpServletResponse">
                            <priority value="INFO" />
                          </category>
                   
                      <category name="com.isomorphic.naming.JNDI">
                        <priority value="WARN" />
                      </category>
                         
                          <category name="com.isomorphic.scripting">
                            <priority value="INFO" />
                          </category>
                   
                          <category name="org.apache.velocity">
                            <priority value="WARN" />
                          </category>
                   
                          <category name="org.hibernate.SQL">
                            <priority value="DEBUG" />
                          </category>
                   
                      <!-- shows values bound to params in SQL query, but produces a lot of output -->
                      <!--
                          <category name="org.hibernate.type">
                            <priority value="DEBUG" />
                       <appender-ref ref="STDOUT"/>
                          </category>
                     -->
                   
                          <!-- embedded tomcat -->
                          <category name="org.apache">
                            <priority value="INFO" />
                        <appender-ref ref="STDOUT"/>
                        <appender-ref ref="SmartClientLog"/>
                          </category>
                   
                      <!-- hibernate log messages -->
                          <category name="org.hibernate">
                            <priority value="DEBUG" />
                        <appender-ref ref="STDOUT"/>
                        <appender-ref ref="SmartClientLog"/>
                          </category>
                         
                        
                         
                  </log4j:configuration>
              log4j.xml
              Code:
              <?xml version="1.0" encoding="UTF-8" ?>
                  <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
                   
                  <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
                         
                         <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
                                  <layout class="org.apache.log4j.PatternLayout">
                                     <param name="ConversionPattern"
                                                    value="=== %d [%.4t] %-5p %c{1} - %m%n"/>
                                  </layout>              
                          </appender>
                   
                          <appender name="FILE_LOG" class="org.apache.log4j.FileAppender">
                              <param name="File"   value="/smartClientServerLog.txt" />
                              <param name="Append" value="false" />              
                              <layout class="org.apache.log4j.PatternLayout">
                                  <param name="ConversionPattern" value="=== %d [%.4t] %-5p %c{1} - %m%n"/>
                              </layout>      
                          </appender>
                   
                      <!-- This appender is used by the "Server Logs" tab in the Developer Console. -->
                          <appender name="SmartClientLog" class="com.isomorphic.log.RevolvingMemoryAppender">
                              <param name="maxEntries" value="500"/>
                          <layout class="org.apache.log4j.PatternLayout">
                                     <param name="ConversionPattern"
                                                    value="=== %d [%.4t] %-5p %c{1} - %m%n"/>
                                  </layout>      
                          </appender>
              			
                          <!-- Custom server log messages -->
                         
                          <category name="de.mks_infofabrik.zedes2.server">
                                  <priority value="DEBUG" />
                                  <appender-ref ref="STDOUT"/>
                                  <appender-ref ref="SmartClientLog"/>
                          </category>
                         
              </log4j:configuration>
              This works, but has some small issues, which I will show next.

              The logs are now shown correctly:
              Code:
              === 2014-10-02 18:09:50,107 [ec-6] DEBUG DeclarativeSecurity - DataSource users is not in the pre-checked list, processing...
              === 2014-10-02 18:09:50,108 [ec-6] ERROR SessionDMIHandler - Session log: error
              === 2014-10-02 18:09:50,108 [ec-6] WARN  SessionDMIHandler - Session log: warn
              === 2014-10-02 18:09:50,108 [ec-6] DEBUG SessionDMIHandler - Session log: debug
              === 2014-10-02 18:09:50,108 [ec-6] INFO  SessionDMIHandler - Session log: info
              === 2014-10-02 18:09:50,108 [ec-6] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
              The issues I mentioned are:
              1) There is a duplicate definition of the appenders. The appenders are defined in both files. If I only define them in one file it doesn't seem to work. So this is not very nice.
              2) We have 2 files :-)
              3) I still see this warning in the logger logs (is it important? )
              Code:
              log4j: Trying to find [log4j.isc.project.config.xml] using context classloader WebappClassLoader
                context: /zedes2
                delegate: false
              ----------> Parent Classloader:
              java.net.URLClassLoader@1d926e41
              .
              log4j: Trying to find [log4j.isc.project.config.xml] using WebappClassLoader
                context: /zedes2
                delegate: false
              ----------> Parent Classloader:
              java.net.URLClassLoader@1d926e41
               class loader.
              log4j: Trying to find [log4j.isc.project.config.xml] using ClassLoader.getSystemResource().
              === 2014-10-02 18:09:40,800 [op-1] INFO  ISCInit - Isomorphic SmartClient/SmartGWT Framework - Initializing
              4) I still have some unformatted logs:
              Code:
              log4j: Retreiving an instance of org.apache.log4j.Logger.
              log4j: Setting [org.hibernate] additivity to [true].
              log4j: Level value for org.hibernate is  [DEBUG].
              log4j: org.hibernate level set to DEBUG
              log4j: Adding appender named [STDOUT] to category [org.hibernate].
              Until now, only the log4j logs are unformatted. All others seem to be formatted.
              Is it possible to format these too ?

              Originally posted by Isomorphic View Post
              Stay tuned, we're looking for the best way for you to get a Logger that has been configured by log4j.isc.config.xml.
              Thank you.
              Last edited by edulid; 2 Oct 2014, 08:33.

              Comment


                #8
                So again, we'll follow up with a way to create a Logger that uses log4j.isc.config.xml settings.

                One your other questions:

                1&2) no there's no way to avoid the appender duplication with 2 files

                3) these startup messages can be ignored. We have to log them at WARN level to give the best chance that you will actually see them if something goes wrong during logging setup and there are no further logs

                4) it's expected that log4j's startup logs would not use patterns that are defined only once log4j has actually been configured.

                Comment


                  #9
                  5) I just discovered a bigger issue with this approach:

                  The Developer Console server logs-settings are being ignored for my categories:
                  e.g. I set in the developer console:
                  de.mks_infofabrik.zedes2.server
                  to ERROR:

                  Code:
                  org.hibernate.SQL: DEBUG
                  org.hibernate: DEBUG
                  org.apache.velocity: WARN
                  org.apache: INFO
                  de.mks_infofabrik.zedes2.server: ERROR
                  com.isomorphic.validation.Validation: INFO
                  com.isomorphic.timing.Timing: INFO
                  com.isomorphic.store.DataStructCache: INFO
                  com.isomorphic.sql.ValueSet: INFO
                  com.isomorphic.servlet.RequestContext: INFO
                  com.isomorphic.servlet.ProxyHttpServletResponse: INFO
                  com.isomorphic.servlet.PreCache: INFO
                  com.isomorphic.scripting: INFO
                  com.isomorphic.resultData.ResultData: INFO
                  com.isomorphic.obfuscation.Obfuscator: INFO
                  com.isomorphic.naming.JNDI: WARN
                  com.isomorphic.js.JSSyntaxScannerFilter: INFO
                  com.isomorphic.interfaces.InterfaceProvider: INFO
                  com.isomorphic.download.Download: INFO
                  com.isomorphic.datasource.DataSource: INFO
                  com.isomorphic.datasource.BasicDataSource: INFO
                  com.isomorphic.datasource.AuditDSGenerator: INFO
                  com.isomorphic.compression.Compression: INFO
                  com.isomorphic.base.Reflection: INFO
                  com.isomorphic.base.ISCInit: INFO
                  com.isomorphic.base.ConfigLoader: INFO
                  com.isomorphic.assembly.FileAssembler: INFO
                  com.isomorphic: DEBUG
                  It seems to be set, BUT when I refresh the window after some server action, I see:
                  Code:
                  === 2014-10-02 18:45:38,959 [ec-2] INFO  DSResponse - [builtinApplication.schueler_fetch] DSResponse: List with 563 items
                  === 2014-10-02 18:45:38,960 [ec-2] ERROR ExcelExportHandler - Excel export log: error
                  === 2014-10-02 18:45:38,960 [ec-2] WARN  ExcelExportHandler - Excel export log: warn
                  === 2014-10-02 18:45:38,960 [ec-2] DEBUG ExcelExportHandler - Excel export log: debug
                  === 2014-10-02 18:45:38,960 [ec-2] INFO  ExcelExportHandler - Excel export log: info
                  === 2014-10-02 18:45:38,979 [ec-2] INFO  ProxyHttpServletResponse - content-disposition set to: attachment; fileName=Export.xls - unwrapping response output stream (CompressionFilter)
                  So the level is being ignored (error, warn, debug and info are being printed).

                  Maybe because, as you explained, I am now using two different Loggers?

                  Edit: Ok, thank you, I will wait for your follow up.
                  Last edited by edulid; 2 Oct 2014, 08:57.

                  Comment


                    #10
                    You may try this approach:
                    Code:
                    private static final org.apache.log4j.Logger LOG = com.isomorphic.log.Logger.getHierarchy().getLogger(SessionDMIHandler.class.getName());
                    getHierarchy() returns exact log4j Logger instance that is configured from log4j.isc.config.xml file, so this way your custom logger configuration will be applied and you won't have duplicating log messages.

                    Alternatively you may declare your logger like this if you are not limited to use log4j logger directly:
                    Code:
                    private static final com.isomorphic.log.Logger LOG = new com.isomorphic.log.Logger(SessionDMIHandler.class);
                    This would work in a same way as first approach above.

                    NOTE these approaches assume, that you will remove log4j.xml leaving only log4j.isc.config.xml configuration and configure your custom logger there (as you did initially).

                    We'd appreciate if you could let us know how it worked for you in the end.
                    Last edited by Isomorphic; 3 Oct 2014, 08:39.

                    Comment


                      #11
                      Thank you, I will try the code and let you know.

                      Comment


                        #12
                        Thanks, it works fine.

                        The dynamic changing of level via console also works.
                        Last edited by edulid; 3 Oct 2014, 11:10.

                        Comment


                          #13
                          Just FYI.

                          Since 10.0 we added documented API to get log4j LoggerRepository (Hierarchy class is deprecated) configured from log4j.isc.config.xml file. Code below demonstrates how it should be used taking your class as an example:
                          Code:
                          private static final org.apache.log4j.Logger LOG = com.isomorphic.util.DataTools.getLoggerRepository().getLogger(SessionDMIHandler.class.getName());
                          This will be available in nightly builds from tomorrow (2014-10-07).

                          Comment


                            #14
                            Originally posted by Isomorphic View Post
                            Just FYI.

                            Since 10.0 we added documented API to get log4j LoggerRepository (Hierarchy class is deprecated) configured from log4j.isc.config.xml file. Code below demonstrates how it should be used taking your class as an example:
                            Code:
                            private static final org.apache.log4j.Logger LOG = com.isomorphic.util.DataTools.getLoggerRepository().getLogger(SessionDMIHandler.class.getName());
                            This will be available in nightly builds from tomorrow (2014-10-07).
                            I am upgrading to 5.1 and when trying to use your code I get this compiling error:
                            The method getLogger(String) is undefined for the type Object

                            Is it safe to cast it?
                            ((Logger) com.isomorphic.util.DataTools.getLoggerRepository()).getLogger(c.getName());

                            Comment


                              #15
                              Yes. That's why the docs tell you what kind of object is being returned.

                              We would make the return signature LoggerRepository except that of course would introduce a dependency.

                              Comment

                              Working...
                              X