Configure TopLink Essentials logging

By default Oracle TopLink uses a TopLink native logger DefaultLogger (oracle.toplink.essentials.logging.DefaultSessionLog). This logger doesn’t offer log level and category settings.

If you try to set a log level, e.g. to get rid of debug output of SQL statement, this setting in persistence.xml won’t have any effect:

<property name="toplink.logging.level.sql" value="WARNING"/>

You have to configure explicitly Java logging in persistence.xml:

<property name="toplink.logging.logger" value="JavaLogger"/>
<property name="toplink.logging.level.sql" value="WARNING"/>

If you are using Spring, you may want to redirect the output to Apache Commons Logging. Spring provides a class org.springframework.orm.toplink.support.CommonsLoggingSessionLog. However, this class works with TopLink full version. To bring it to work with TopLink Essentials, grab the CommonsLoggingSessionLog source and change all imports starting with oracle.toplink to oracle.toplink.essentials.

Finally, register your new SessionLog implementation in persistence.xml:

<property name="toplink.logging.logger" value="foo.MyTopLinkEssentialsCommonsLoggingSessionLog"/>

For more information on settings, refer to TopLink Essentials documentation on logging.

Advertisements

2 thoughts on “Configure TopLink Essentials logging

  1. It works well. Thanks.I had to add -Dlog4j.ignoreTCL=true as argument of my Tomcat container because the ClassLoader was complaining.

  2. Thank you for the tip.In my case I changed logging in a standalone server. I didn't have to cope with app server classloaders.

Comments are closed.