Announcement

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

    Problem Getting Log4j to Work

    I am having a problem when trying to run the builtinds sample project in Eclipse. I get this warning in the console:

    log4j:WARN No appenders could be found for logger (org.apache.jasper.compiler.JspRuntimeContext).
    log4j:WARN Please initialize the log4j system properly.

    I have the log4j.isc.config.xml file in the src directory, and this are the contents of the file:

    Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    
        <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>
    What am I missing here?

    Thanks

    SmartClient Version: v10.1p_2015-12-13/Pro Deployment (built 2015-12-13)

    #2
    Make sure that the log4j.isc.config.xml file actually ends up in the WEB-INF/classes directory when your servlet engine is started. Eclipse normally will do this for any files in the "src" area of your project, but perhaps your project is configured differently.

    Comment


      #3
      Thanks for your reply. I just checked, and I can see the file is there. What else can it be? The weird thing is that this won't work even in the sample projects...

      Comment


        #4
        Try showing all the logs you get, both before and after you see the log about log4j not being initialized (and please always do this when posting - partial logs almost always omit key information).

        Comment


          #5
          Here it is:

          Code:
          Runing CodeServer with parameters: [-noprecompile, -port, 9876, -sourceLevel, 1.7, -bindAddress, 127.0.0.1, -launcherDir, D:\Dropbox\Desarrollo\Java\Workspaces\SmartGWTSamples\builtinds\war, -logLevel, INFO, com.smartgwt.sample.BuiltInDS]
          Super Dev Mode starting up
             workDir: C:\Users\carlo\AppData\Local\Temp\gwt-codeserver-6607162141275837595.tmp
             Loading Java files in com.smartgwt.sample.BuiltInDS.
          [Server@becb3c9]: [Thread[main,5,main]]: checkRunning(false) entered
          [Server@becb3c9]: [Thread[main,5,main]]: checkRunning(false) exited
          [Server@becb3c9]: Startup sequence initiated from main() method
          [Server@becb3c9]: Could not load properties from file
          [Server@becb3c9]: Using cli/default properties only
          [Server@becb3c9]: Initiating startup sequence...
          [Server@becb3c9]: Server socket opened successfully in 1 ms.
          log4j:WARN No appenders could be found for logger (hsqldb.db.HSQLDB5064A17199.ENGINE).
          log4j:WARN Please initialize the log4j system properly.
          [Server@becb3c9]: Database [index=0, id=0, db=file:D:\Dropbox\Desarrollo\Java\Workspaces\SmartGWTSamples\builtinds\war\WEB-INF\db\hsqldb\isomorphic, alias=isomorphic] opened sucessfully in 1160 ms.
          [Server@becb3c9]: Startup sequence completed in 1164 ms.
          [Server@becb3c9]: 2015-12-15 19:06:31.335 HSQLDB server 2.3.3 is online on port 9001
          [Server@becb3c9]: To close normally, connect and execute SHUTDOWN SQL
          [Server@becb3c9]: From command line, use [Ctrl]+[C] to abort abruptly
          ISC: Configuring log4j from: file:/D:/Dropbox/Desarrollo/Java/Workspaces/SmartGWTSamples/builtinds/war/WEB-INF/classes/log4j.isc.config.xml
          === 2015-12-15 19:06:31,474 [main] INFO  ISCInit - Isomorphic SmartClient/SmartGWT Framework - Initializing
          === 2015-12-15 19:06:31,480 [main] INFO  ConfigLoader - Attempting to load framework.properties from CLASSPATH
          === 2015-12-15 19:06:31,551 [main] INFO  ConfigLoader - Successfully loaded framework.properties from CLASSPATH at location: jar:file:/D:/Dropbox/Desarrollo/Java/Workspaces/SmartGWTSamples/builtinds/war/WEB-INF/lib/isomorphic_core_rpc.jar!/framework.properties
          === 2015-12-15 19:06:31,552 [main] INFO  ConfigLoader - Attempting to load project.properties from CLASSPATH
          === 2015-12-15 19:06:31,553 [main] INFO  ConfigLoader - Unable to locate project.properties in CLASSPATH
          === 2015-12-15 19:06:31,557 [main] INFO  ConfigLoader - Successfully loaded isc_interfaces.properties from CLASSPATH at location: jar:file:/D:/Dropbox/Desarrollo/Java/Workspaces/SmartGWTSamples/builtinds/war/WEB-INF/lib/isomorphic_core_rpc.jar!/isc_interfaces.properties
          === 2015-12-15 19:06:31,558 [main] INFO  ConfigLoader - Attempting to load server.properties from CLASSPATH
          === 2015-12-15 19:06:31,564 [main] INFO  ConfigLoader - Successfully loaded server.properties from CLASSPATH at location: file:/D:/Dropbox/Desarrollo/Java/Workspaces/SmartGWTSamples/builtinds/war/WEB-INF/classes/server.properties
          === 2015-12-15 19:06:31,572 [main] INFO  Logger - Logging system started.
          === 2015-12-15 19:06:31,574 [main] DEBUG ConfigParser - Matched var name: gwtModuleName
          === 2015-12-15 19:06:31,575 [main] DEBUG ConfigParser - value after substitution: builtinds/sc
          === 2015-12-15 19:06:31,575 [main] INFO  ISCInit - Auto-detected webRoot - using: D:\Dropbox\Desarrollo\Java\Workspaces\SmartGWTSamples\builtinds\war
          === 2015-12-15 19:06:31,576 [main] INFO  ISCInit - Isomorphic SmartClient/SmartGWT Framework (v10.0p_2015-10-14/EVAL Deployment 2015-10-14) - Initialization Complete
          log4j:WARN No appenders could be found for logger (org.apache.jasper.compiler.JspRuntimeContext).
          log4j:WARN Please initialize the log4j system properly.
          Linking modules
             Bootstrap link for command-line module 'com.smartgwt.sample.BuiltInDS'
                Linking module 'builtinds'
                   Invoking Linker Cross-Site-Iframe
                      Ignoring the following script tags in the gwt.xml file
          sc/initsc.js
          sc/modules/ISC_Core.js
          sc/modules/ISC_Foundation.js
          sc/modules/ISC_Containers.js
          sc/modules/ISC_Grids.js
          sc/modules/ISC_Forms.js
          sc/modules/ISC_RichTextEditor.js
          sc/modules/ISC_Calendar.js
          sc/modules/ISC_DataBinding.js
          sc/skins/Enterprise/load_skin.js
          
             Invoking Linker SmartGwtScriptInjector
                Creating loadScriptTagFiles.js to manually load the following script tags:
          sc/initsc.js
          sc/modules/ISC_Core.js
          sc/modules/ISC_Foundation.js
          sc/modules/ISC_Containers.js
          sc/modules/ISC_Grids.js
          sc/modules/ISC_Forms.js
          sc/modules/ISC_RichTextEditor.js
          sc/modules/ISC_Calendar.js
          sc/modules/ISC_DataBinding.js
          sc/skins/Enterprise/load_skin.js
             Module setup completed in 21898 ms
          
          The code server is ready at http://127.0.0.1:9876/
          Code server started in 22241 ms
          waited 12766 ms for code server to finish
          Thanks

          Comment


            #6
            Despite the warning message, this appears to show log4j initializing properly:

            ISC: Configuring log4j from: file:/D:/Dropbox/Desarrollo/Java/Workspaces/SmartGWTSamples/builtinds/war/WEB-INF/classes/log4j.isc.config.xml === 2015-12-15 19:06:31,474 [main] INFO ISCInit - Isomorphic SmartClient/SmartGWT Framework - Initializing
            What's the problem? Are you not seeing expected logs after this point?

            Comment


              #7
              Well, since the warning is shown more than once, I don't really know if that's normal behavior. Is it?
              Thanks

              Comment


                #8
                No, it's not, so something is definitely wrong with your project, such as duplicate .jars, a classloader issue, or some other reason log4j is initialized 3 times over.

                But so long as you are receiving logs from our software, you may not need to worry about it.

                Comment


                  #9
                  Thanks for all your help. I'll try to find some time to import the sample project starting from scratch, to see if this keeps happening.

                  Comment

                  Working...
                  X