Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Problems with log4j

$
0
0
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).

Viewing all articles
Browse latest Browse all 4756

Trending Articles