You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Alexey Romanov <al...@gmail.com> on 2012/11/30 06:43:39 UTC

Configuring OpenJPA to log in Karaf 2.3.0

How can I get OpenJPA to log SQL requests, etc.? I expected setting

log4j.category.openjpa.Tool=INFO
log4j.category.openjpa.Runtime=INFO
log4j.category.openjpa.Remote=INFO
log4j.category.openjpa.DataCache=INFO
log4j.category.openjpa.MetaData=INFO
log4j.category.openjpa.Enhance=INFO
log4j.category.openjpa.Query=INFO
log4j.category.openjpa.jdbc.SQL=INFO
log4j.category.openjpa.jdbc.SQLDiag=INFO
log4j.category.openjpa.jdbc.JDBC=INFO
log4j.category.openjpa.jdbc.Schema=INFO

in org.ops4j.pax.logging.cfg and

<property name="openjpa.Log" value="slf4j" />

in persistence.xml would work (due to
http://karaf.922171.n3.nabble.com/log4j-error-with-pax-logging-tt2459109.html#none)
but it doesn't. And if I set openjpa.Log to log4j instead, in previous
versions I got java.lang.NoClassDefFoundError: org/apache/log4j/LogManager,
but with Karaf 2.3.0 my bundle fails to start instead, waiting for a
dependency:

2012-11-29 17:40:28,931 | INFO  | rint Extender: 1 |
BlueprintContainerImpl           |
  container.BlueprintContainerImpl  330 | 7 -
org.apache.aries.blueprint.core - 1.0.1 |
  Bundle ru.focusmedia.odp.server.datastore.jpa is waiting for dependencies

  [(&(&(!(org.apache.aries.jpa.proxy.factory=*))(osgi.unit.name=ODP_Server))(objectClass=javax.persistence.EntityManagerFactory))]

Yours, Alexey Romanov

Re: Configuring OpenJPA to log in Karaf 2.3.0

Posted by Alexey Romanov <al...@gmail.com>.
> logging from your bundles using slf4j works?

Yes, including the persistence bundle itself.

> You'vent changed the startup order, did you?

No, I didn't (though I set OpenJPA itself to startlevel 50, so it starts
before my persistence bundle, but that's still later than Pax Logging).

Yours, Alexey Romanov


On Fri, Nov 30, 2012 at 1:53 PM, Andreas Pieber [via Karaf] <
ml-node+s922171n4026971h60@n3.nabble.com> wrote:

> logging
> from your bundles using slf4j works?
>




--
View this message in context: http://karaf.922171.n3.nabble.com/Configuring-OpenJPA-to-log-in-Karaf-2-3-0-tp4026959p4026974.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Configuring OpenJPA to log in Karaf 2.3.0

Posted by Andreas Pieber <an...@gmail.com>.
yep, I'm only using the default org.ops4j.pax.logging.cfg coming with karaf

Kind regards,
Andreas

On Fri, Nov 30, 2012 at 11:12 AM, Alexey Romanov
<al...@gmail.com> wrote:
>> I've no changes in my logging configuration.
>
> Does that mean you have no log4j.category.openjpa.* properties in
> org.ops4j.pax.logging.cfg?
>
> Yours, Alexey Romanov
>
>
> On Fri, Nov 30, 2012 at 1:53 PM, Andreas Pieber [via Karaf] <
> ml-node+s922171n4026971h60@n3.nabble.com> wrote:
>
>> TBH I've never tried log4j, but I'm curious that slf4j does not work
>> for you.  My persistence.xml looks like:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
>>
>>     <persistence-unit name="rx.physikodata" transaction-type="JTA">
>>
>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>         <jta-data-source>osgi:service/javax.sql.DataSource/(
>> osgi.jndi.service.name=jdbc/rx)</jta-data-source>
>>         LIST_OF_CLASSES_TO_SCAN
>>         <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>         <validation-mode>NONE</validation-mode>
>>         <properties>
>>             <property name="openjpa.Log" value="slf4j"/>
>>             <property name="openjpa.RuntimeUnenhancedClasses"
>> value="supported"/>
>>         </properties>
>>     </persistence-unit>
>> </persistence>
>>
>> and it works like a charm. I've no changes in my logging
>> configuration. Maybe it's something completely differently? logging
>> from your bundles using slf4j works? You'vent changed the startup
>> order, did you?
>>
>> Kind regards,
>> Andreas
>>
>> On Fri, Nov 30, 2012 at 9:25 AM, Alexey Romanov
>> <[hidden email] <http://user/SendEmail.jtp?type=node&node=4026971&i=0>>
>> wrote:
>> > Same thing was happening with "slf4j"/"commons" back in Karaf 2.2.7, but
>> it
>> > threw an exception on "log4j".
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://karaf.922171.n3.nabble.com/Configuring-OpenJPA-to-log-in-Karaf-2-3-0-tp4026959p4026967.html
>> > Sent from the Karaf - User mailing list archive at Nabble.com.
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://karaf.922171.n3.nabble.com/Configuring-OpenJPA-to-log-in-Karaf-2-3-0-tp4026959p4026971.html
>>  To unsubscribe from Configuring OpenJPA to log in Karaf 2.3.0, click here<http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4026959&code=YWxleGV5LnYucm9tYW5vdkBnbWFpbC5jb218NDAyNjk1OXwtNDYxNDY2Mjc3>
>> .
>> NAML<http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Configuring-OpenJPA-to-log-in-Karaf-2-3-0-tp4026959p4026976.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Configuring OpenJPA to log in Karaf 2.3.0

Posted by Alexey Romanov <al...@gmail.com>.
> I've no changes in my logging configuration.

Does that mean you have no log4j.category.openjpa.* properties in
org.ops4j.pax.logging.cfg?

Yours, Alexey Romanov


On Fri, Nov 30, 2012 at 1:53 PM, Andreas Pieber [via Karaf] <
ml-node+s922171n4026971h60@n3.nabble.com> wrote:

> TBH I've never tried log4j, but I'm curious that slf4j does not work
> for you.  My persistence.xml looks like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
>
>     <persistence-unit name="rx.physikodata" transaction-type="JTA">
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>         <jta-data-source>osgi:service/javax.sql.DataSource/(
> osgi.jndi.service.name=jdbc/rx)</jta-data-source>
>         LIST_OF_CLASSES_TO_SCAN
>         <exclude-unlisted-classes>true</exclude-unlisted-classes>
>         <validation-mode>NONE</validation-mode>
>         <properties>
>             <property name="openjpa.Log" value="slf4j"/>
>             <property name="openjpa.RuntimeUnenhancedClasses"
> value="supported"/>
>         </properties>
>     </persistence-unit>
> </persistence>
>
> and it works like a charm. I've no changes in my logging
> configuration. Maybe it's something completely differently? logging
> from your bundles using slf4j works? You'vent changed the startup
> order, did you?
>
> Kind regards,
> Andreas
>
> On Fri, Nov 30, 2012 at 9:25 AM, Alexey Romanov
> <[hidden email] <http://user/SendEmail.jtp?type=node&node=4026971&i=0>>
> wrote:
> > Same thing was happening with "slf4j"/"commons" back in Karaf 2.2.7, but
> it
> > threw an exception on "log4j".
> >
> >
> >
> > --
> > View this message in context:
> http://karaf.922171.n3.nabble.com/Configuring-OpenJPA-to-log-in-Karaf-2-3-0-tp4026959p4026967.html
> > Sent from the Karaf - User mailing list archive at Nabble.com.
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://karaf.922171.n3.nabble.com/Configuring-OpenJPA-to-log-in-Karaf-2-3-0-tp4026959p4026971.html
>  To unsubscribe from Configuring OpenJPA to log in Karaf 2.3.0, click here<http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4026959&code=YWxleGV5LnYucm9tYW5vdkBnbWFpbC5jb218NDAyNjk1OXwtNDYxNDY2Mjc3>
> .
> NAML<http://karaf.922171.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://karaf.922171.n3.nabble.com/Configuring-OpenJPA-to-log-in-Karaf-2-3-0-tp4026959p4026976.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Configuring OpenJPA to log in Karaf 2.3.0

Posted by Andreas Pieber <an...@gmail.com>.
TBH I've never tried log4j, but I'm curious that slf4j does not work
for you.  My persistence.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
    <persistence-unit name="rx.physikodata" transaction-type="JTA">
        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
        <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/rx)</jta-data-source>
        LIST_OF_CLASSES_TO_SCAN
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
        <validation-mode>NONE</validation-mode>
        <properties>
            <property name="openjpa.Log" value="slf4j"/>
            <property name="openjpa.RuntimeUnenhancedClasses"
value="supported"/>
        </properties>
    </persistence-unit>
</persistence>

and it works like a charm. I've no changes in my logging
configuration. Maybe it's something completely differently? logging
from your bundles using slf4j works? You'vent changed the startup
order, did you?

Kind regards,
Andreas

On Fri, Nov 30, 2012 at 9:25 AM, Alexey Romanov
<al...@gmail.com> wrote:
> Same thing was happening with "slf4j"/"commons" back in Karaf 2.2.7, but it
> threw an exception on "log4j".
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Configuring-OpenJPA-to-log-in-Karaf-2-3-0-tp4026959p4026967.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Configuring OpenJPA to log in Karaf 2.3.0

Posted by Alexey Romanov <al...@gmail.com>.
Same thing was happening with "slf4j"/"commons" back in Karaf 2.2.7, but it
threw an exception on "log4j".



--
View this message in context: http://karaf.922171.n3.nabble.com/Configuring-OpenJPA-to-log-in-Karaf-2-3-0-tp4026959p4026967.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Configuring OpenJPA to log in Karaf 2.3.0

Posted by Alexey Romanov <al...@gmail.com>.
When I have 

<property name="openjpa.Log" value="slf4j" /> 

or 

<property name="openjpa.Log" value="commons" /> 

it works but doesn't log (logging in my own code using SLF4J works).

When I have

<property name="openjpa.Log" value="log4j" /> 

it doesn't work (Blueprint column in Karaf console `list` output shows
GracePeriod instead of Created).




--
View this message in context: http://karaf.922171.n3.nabble.com/Configuring-OpenJPA-to-log-in-Karaf-2-3-0-tp4026959p4026966.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Configuring OpenJPA to log in Karaf 2.3.0

Posted by Andreas Pieber <an...@gmail.com>.
and when you remove the line:

<property name="openjpa.Log" value="slf4j" />

it works again?

Kind regards,
Andreas

On Fri, Nov 30, 2012 at 6:43 AM, Alexey Romanov
<al...@gmail.com> wrote:
> How can I get OpenJPA to log SQL requests, etc.? I expected setting
>
> log4j.category.openjpa.Tool=INFO
> log4j.category.openjpa.Runtime=INFO
> log4j.category.openjpa.Remote=INFO
> log4j.category.openjpa.DataCache=INFO
> log4j.category.openjpa.MetaData=INFO
> log4j.category.openjpa.Enhance=INFO
> log4j.category.openjpa.Query=INFO
> log4j.category.openjpa.jdbc.SQL=INFO
> log4j.category.openjpa.jdbc.SQLDiag=INFO
> log4j.category.openjpa.jdbc.JDBC=INFO
> log4j.category.openjpa.jdbc.Schema=INFO
>
> in org.ops4j.pax.logging.cfg and
>
> <property name="openjpa.Log" value="slf4j" />
>
> in persistence.xml would work (due to
> http://karaf.922171.n3.nabble.com/log4j-error-with-pax-logging-tt2459109.html#none)
> but it doesn't. And if I set openjpa.Log to log4j instead, in previous
> versions I got java.lang.NoClassDefFoundError: org/apache/log4j/LogManager,
> but with Karaf 2.3.0 my bundle fails to start instead, waiting for a
> dependency:
>
> 2012-11-29 17:40:28,931 | INFO  | rint Extender: 1 | BlueprintContainerImpl
> |
>   container.BlueprintContainerImpl  330 | 7 -
> org.apache.aries.blueprint.core - 1.0.1 |
>   Bundle ru.focusmedia.odp.server.datastore.jpa is waiting for dependencies
>
>
>
> [(&(&(!(org.apache.aries.jpa.proxy.factory=*))(osgi.unit.name=ODP_Server))(objectClass=javax.persistence.EntityManagerFactory))]
>
> Yours, Alexey Romanov