LoginSignup
4
4

More than 5 years have passed since last update.

openjpa logging configuration with slf4j.

Last updated at Posted at 2014-04-22

summary

  1. Declare a property which configure openjpa to use slf4j in persistence.xml
  2. Declare loggers in logback.xml with names of Logging Channels

example

persistence.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
 <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>

        <properties>
            <property name="openjpa.Log" value="slf4j"/><!-- Details are specified in logback.ml -->
        </properties>
    </persistence-unit>
</persistence>
logback.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE logback>
<configuration debug="false">
<logger name="openjpa.Runtime" level="OFF">
   <appender-ref ref="someAppender" />
</logger>
</configuration>

reference

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4