Announcement Announcement Module
Collapse
No announcement yet.
getting debug level messages from Spring in SpringPortletMVC application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • getting debug level messages from Spring in SpringPortletMVC application

    Hi Spring Forum members,

    I am having problems producing Spring debug messages for my portlet application. I am using log4j successfully for my other log needs. When I add the spring framework class to it nothing is produced. I have seen in the Petclinic application that web.xml entries were necessary, but when I copied them into my app it still did nothing.

    Can someone point me to a clear example to accomplish this using log4j?

    Thanks in advance!

    Steve

  • #2
    Post your web.xml and log4j.xml / log4j.properties. Also, on which portal server are you deploying your portlets? Liferay? IBM WPS?

    Comment


    • #3
      Hi Enrico,

      Thanks for the response.

      I am using JDeveloper / webcenter 11.1.1.4. It is an integrated IDE with a local weblogic server.

      Here are the files you requested:

      log4j.xml - I do not have one (!)

      log4j.properties -

      # Root logger option
      # log4j.rootLogger=WARN, file, console
      log4j.rootLogger=DEBUG, file, console
      # Direct log messages to a log file
      log4j.appender.file=org.apache.log4j.RollingFileAp pender
      # this path may need to be filtered, or standardized
      log4j.appender.file.File=C:\\ROI\\logs\\roi-portlets.log
      log4j.appender.file.MaxFileSize=1MB
      log4j.appender.file.MaxBackupIndex=5
      log4j.appender.file.layout=org.apache.log4j.Patter nLayout
      log4j.appender.file.layout.ConversionPattern=%d{AB SOLUTE} %5p %c{1}:%L - %m%n
      log4j.appender.file.org.springframework=DEBUG

      # Direct log messages to Console
      log4j.appender.console=org.apache.log4j.ConsoleApp ender
      log4j.appender.console.Target=System.out
      log4j.appender.console.layout=org.apache.log4j.Pat ternLayout
      log4j.appender.console.layout.ConversionPattern=%d {ABSOLUTE} %5p %c{1}:%L - %m%n
      log4j.appender.console.org.springframework=DEBUG

      log4j.category.gov.opm.epic.roi=TRACE
      log4j.logger.org.springframework=DEBUG
      log4j.category.org.hibernate=ERROR



      web.xml -


      <?xml version = '1.0' encoding = 'windows-1252'?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">

      <display-name>ROI Review</display-name>
      <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/context/applicationContext.xml</param-value>
      </context-param>

      <!--
      Key of the system property that should specify the root directory of this
      web app. Applied by WebAppRootListener or Log4jConfigListener.
      steve chg from petclinic.root to /
      -->
      <context-param>
      <param-name>webAppRootKey</param-name>
      <param-value>/</param-value>
      </context-param>

      <!--
      Location of the Log4J config file, for initialization and refresh checks.
      Applied by Log4jConfigListener.
      -->
      <context-param>

      <param-name>log4jConfigLocation</param-name>
      <param-value>/WEB-INF/classes/log4j.properties</param-value>
      </context-param>
      <!--
      - Configures Log4J for this web app.
      - As this context specifies a context-param "log4jConfigLocation", its file path
      - is used to load the Log4J configuration, including periodic refresh checks.
      -
      - Would fall back to default Log4J initialization (non-refreshing) if no special
      - context-params are given.
      -
      - Exports a "web app root key", i.e. a system property that specifies the root
      - directory of this web app, for usage in log file paths.
      - This web app specifies "petclinic.root" (see log4j.properties file).
      -->
      <!-- Leave the listener commented-out if using JBoss -->
      <filter>
      <filter-name>JpsFilter</filter-name>
      <filter-class>oracle.security.jps.ee.http.JpsFilter</filter-class>
      <init-param>
      <param-name>enable.anonymous</param-name>
      <param-value>true</param-value>
      </init-param>
      </filter>
      <filter-mapping>
      <filter-name>JpsFilter</filter-name>
      <url-pattern>/*</url-pattern>
      <dispatcher>FORWARD</dispatcher>
      <dispatcher>REQUEST</dispatcher>
      <dispatcher>INCLUDE</dispatcher>
      </filter-mapping>
      <listener>
      <listener-class>org.springframework.web.util.Log4jConfigList ener</listener-class>
      </listener>




      <listener>
      <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
      </listener>

      <servlet>
      <servlet-name>ViewRendererServlet</servlet-name>
      <servlet-class>org.springframework.web.servlet.ViewRenderer Servlet</servlet-class>
      <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet-mapping>
      <servlet-name>ViewRendererServlet</servlet-name>
      <url-pattern>/WEB-INF/servlet/view</url-pattern>
      </servlet-mapping>

      <!-- Change spring tag lib from /WEB-INF/ to classpath -->
      <jsp-config>
      <taglib>
      <taglib-uri>/WEB-INF/spring.tld</taglib-uri>
      <taglib-location>classpath:spring.tld</taglib-location>
      </taglib>
      <taglib>
      <taglib-uri>/WEB-INF/spring-form.tld</taglib-uri>
      <taglib-location>classpath:spring.tld</taglib-location>
      </taglib>
      </jsp-config>
      </web-app>

      Thanks !
      STeve

      Comment


      • #4
        Hi,

        next time please use CODE tags to post your code / xml / stacktraces.
        For Weblogic server there is a known issue about log4j...just adding the log4j.properties or log4j.xml to the root of the webapp classpath doesn't make it work, as it does in other containers and as it should.
        This is due to how Weblogic classloaders stack works, I won't enter in any detail because this has nothing to do with Spring, but you can google the issue if you're interested.

        Comment

        Working...
        X