You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by Craig L Russell <Cr...@Sun.COM> on 2010/03/08 21:24:47 UTC

Logging settings

Hi,

I'm trying to do a few simple things with logging, and having trouble.

1. Disable WARN messages from the enhancer.

2. Get SQL TRACE messages.

I've tried unsuccessfully to get either of these to work. I'm using  
the standard OpenJPA logging, and get a few hundred messages out of  
the enhancer, so I know logging is basically working.

Reading everything I can about the logging system, I tried to get the  
enhancer to stop logging WARN but only log ERROR:

-Dopenjpa.Log=none

I still get WARN messages; don't get any errors from the logging  
system; it looks like the enhancer is just ignoring this setting

-Dopenjpa.Log=SQL=TRACE,File=openjpaLogger.log

I get output sent to openjpaLogger.log file as expected, but nothing  
of interest. Just:

11  TRACE  [main] openjpa.Runtime - Default configuration information  
couldn't be loaded from any configuration provider.0  TRACE  [main]  
openjpa.Runtime - Default configuration information couldn't be loaded  
from any configuration provider.
17  WARN   [main] openjpa.Runtime - The configuration property named  
"openjpa.LogLevel" was not recognized and will be ignored, although  
the name closely matches a valid property called "openjpa.Log".
17  TRACE  [main] openjpa.Runtime - Default configuration information  
couldn't be loaded from any configuration provider.
2  WARN   [main] openjpa.Runtime - The configuration property named  
"openjpa.LogLevel" was not recognized and will be ignored, although  
the name closely matches a valid property called "openjpa.Log".
2  TRACE  [main] openjpa.Runtime - Default configuration information  
couldn't be loaded from any configuration provider.
10  TRACE  [main] openjpa.Runtime - Default configuration information  
couldn't be loaded from any configuration provider.

And where did it get the LogLevel? I didn't set this property!

Can anyone point me in the right direction? Is the -Dopenjpa.Log  
useful for anything or do I have to use persistence.xml properties (I  
haven't tried this since there are hundreds of persistence.xml files  
that I would need to fiddle).

Thanks,

Craig

Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Logging settings

Posted by Kevin Sutter <kw...@gmail.com>.
Hi Craig,
On Tue, Mar 9, 2010 at 12:21 AM, Craig L Russell <Cr...@sun.com>wrote:

>
> Any ideas why adding properties to the command line or persistence.xml
> doesn't take effect for tests, but adding the properties to setup does work?
>

Nothing other than some ol' fashioned debugging...  :-)  As the OpenJPA
manual section [1] pointed out, any properties sent in via a Map when
creating the EMF/EM will override any previous settings, including the
persistence.xml.  So, at least that explains why calling setup() with
properties is picking up the settings like you requested.

Maybe there's something in the testcase setup processing that is deleting or
overriding any previously set properties (in order to make the tests
repeatable).  Or, maybe there's a bug in the way that the Map is processed
and it's accidentally overriding properties that are not meant to be
overridden.  This might just take some debugging to figure out why this
isn't working as expected.

Kevin

[1]
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_conf_specify


On Tue, Mar 9, 2010 at 12:21 AM, Craig L Russell <Cr...@sun.com>wrote:

> Hi Kevin,
>
> I did a little more experimentation. There are two persistence units in the
> persistence.xml: xml-persistence-unit and test.
>
> I can override the settings of the xml-persistence-unit on the command
> line.
>
> So the settings for File, DefaultLevel, Tool, Enhance, MetaData are all
> getting set properly for enhancement.
>
> But the log settings I put into the persistence unit test are not taking
> effect properly. To verify that I'm using the right persistence unit, I
> deliberately caused an error and the error was reported.
>
> But even with setting openjpa.Log in the persistence unit, I still get
> console logging:
>
> Running org.apache.openjpa.persistence.identity.TestSQLBigIntegerId
> TestSQLBigIntegerId 1268089380000
> 543  test  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.3.0-SNAPSHOT
> 5763  test  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class
> "org.apache.openjpa.jdbc.sql.MySQLDictionary" (MySQL
> 5.1.41-ndb-7.1.2-beta-debug ,MySQL-AB JDBC Driver
> mysql-connector-java-5.1.12 ( Revision: ${bzr.revision-id} )).
> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.698 sec
>
> I modified a test case to put the logging information into the setup string
> and this changed the behavior of the logger.
>
>    public void setUp() {
>        setUp(SQLBigIntegerIdEntity.class
>                , "openjpa.Log",
> "File=openjpaLogger.log,DefaultLevel=INFO,SQL=TRACE,JDBC=TRACE"
>                );
>    }
>
> Any ideas why adding properties to the command line or persistence.xml
> doesn't take effect for tests, but adding the properties to setup does work?
>
> Thanks,
>
> Craig
>
>
> On Mar 8, 2010, at 2:25 PM, Kevin Sutter wrote:
>
>  Hi Craig,
>> We have found exceptions to the rules, but the order of property
>> configuration is documented in this section [1] of the manual.  Based on
>> what you have provided, my guess is that some of your persistence.xml
>> file(s) are overriding the system properties you are trying to set.
>>
>> I don't personally use the system properties, but I would guess you need
>> to
>> enclose the values in quotes.  So, I would try that for setting the
>> openjpa.Log property.
>>
>> Good luck!
>> Kevin
>>
>> [1]
>>
>> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_conf_specify
>>
>> On Mon, Mar 8, 2010 at 2:24 PM, Craig L Russell <Craig.Russell@sun.com
>> >wrote:
>>
>>  Hi,
>>>
>>> I'm trying to do a few simple things with logging, and having trouble.
>>>
>>> 1. Disable WARN messages from the enhancer.
>>>
>>> 2. Get SQL TRACE messages.
>>>
>>> I've tried unsuccessfully to get either of these to work. I'm using the
>>> standard OpenJPA logging, and get a few hundred messages out of the
>>> enhancer, so I know logging is basically working.
>>>
>>> Reading everything I can about the logging system, I tried to get the
>>> enhancer to stop logging WARN but only log ERROR:
>>>
>>> -Dopenjpa.Log=none
>>>
>>> I still get WARN messages; don't get any errors from the logging system;
>>> it
>>> looks like the enhancer is just ignoring this setting
>>>
>>> -Dopenjpa.Log=SQL=TRACE,File=openjpaLogger.log
>>>
>>> I get output sent to openjpaLogger.log file as expected, but nothing of
>>> interest. Just:
>>>
>>> 11  TRACE  [main] openjpa.Runtime - Default configuration information
>>> couldn't be loaded from any configuration provider.0  TRACE  [main]
>>> openjpa.Runtime - Default configuration information couldn't be loaded
>>> from
>>> any configuration provider.
>>> 17  WARN   [main] openjpa.Runtime - The configuration property named
>>> "openjpa.LogLevel" was not recognized and will be ignored, although the
>>> name
>>> closely matches a valid property called "openjpa.Log".
>>> 17  TRACE  [main] openjpa.Runtime - Default configuration information
>>> couldn't be loaded from any configuration provider.
>>> 2  WARN   [main] openjpa.Runtime - The configuration property named
>>> "openjpa.LogLevel" was not recognized and will be ignored, although the
>>> name
>>> closely matches a valid property called "openjpa.Log".
>>> 2  TRACE  [main] openjpa.Runtime - Default configuration information
>>> couldn't be loaded from any configuration provider.
>>> 10  TRACE  [main] openjpa.Runtime - Default configuration information
>>> couldn't be loaded from any configuration provider.
>>>
>>> And where did it get the LogLevel? I didn't set this property!
>>>
>>> Can anyone point me in the right direction? Is the -Dopenjpa.Log useful
>>> for
>>> anything or do I have to use persistence.xml properties (I haven't tried
>>> this since there are hundreds of persistence.xml files that I would need
>>> to
>>> fiddle).
>>>
>>> Thanks,
>>>
>>> Craig
>>>
>>> Craig L Russell
>>> Architect, Sun Java Enterprise System http://db.apache.org/jdo
>>> 408 276-5638 mailto:Craig.Russell@sun.com
>>> P.S. A good JDO? O, Gasp!
>>>
>>>
>>>
> Craig L Russell
> Architect, Sun Java Enterprise System http://db.apache.org/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com
> P.S. A good JDO? O, Gasp!
>
>

Re: Logging settings

Posted by Michael Dick <mi...@gmail.com>.
Might be a bit of a tangent, but the kludge in pom.xml is something I added
a while back. I wanted a way to set a consistent log level for the general
build, and went with the openjpa.loglevel property. It might have been more
intuitive to just specify -Dopenjpa.Log=... on the maven command line. If I
remember correctly that wasn't passed along to surefire, or the PCEnhancer
task though.

Anyway that's why it ended up the way it is. It probably needs to be looked
at again though - it looks like it's intercepting Craig's logging settings
and overriding them.

-mike

On Tue, Mar 9, 2010 at 8:11 AM, Donald Woods <dw...@apache.org> wrote:

> Are these junit 3.x tests?  Running under surefire?
>
> I run the standard junits as part of trunk builds all the time and turn
> off most of the logging (as I get tired of seeing all those enhancement
> warnings too), by using cmdline options -
>
>        mvn clean install -Dopenjpa.loglevel=ERROR
>
> The above definitely turns off everything but ERROR messages.
> But, our pom.xml has special setups in them, like providing a default of -
>    <openjpa.loglevel>INFO</openjpa.loglevel>
>
> and then passing them to surefire as -
>    <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-surefire-plugin</artifactId>
>        <configuration>
>            <argLine>${surefire.jvm.args}</argLine>
>            <systemProperties>
>                <property>
>                    <name>openjpa.Log</name>
>                    <value>DefaultLevel=${openjpa.loglevel</value>
>                </property>
>        . . .
>
> The enhancer.xml ANT script gets "openjpa.loglevel" passed in and then
> it remaps it to the expected settings as above.
>
> A couple months back we had a Geronimo user asking about OpenJPA logging
> and they were able to configure custom loglevel and Log file output in
> their persistence.xml using the 1.2.1 level without problems, so it
> should be doable.....
>
>
> -Donald
>
>
> On 3/9/10 1:21 AM, Craig L Russell wrote:
> > Hi Kevin,
> >
> > I did a little more experimentation. There are two persistence units in
> > the persistence.xml: xml-persistence-unit and test.
> >
> > I can override the settings of the xml-persistence-unit on the command
> > line.
> >
> > So the settings for File, DefaultLevel, Tool, Enhance, MetaData are all
> > getting set properly for enhancement.
> >
> > But the log settings I put into the persistence unit test are not taking
> > effect properly. To verify that I'm using the right persistence unit, I
> > deliberately caused an error and the error was reported.
> >
> > But even with setting openjpa.Log in the persistence unit, I still get
> > console logging:
> >
> > Running org.apache.openjpa.persistence.identity.TestSQLBigIntegerId
> > TestSQLBigIntegerId 1268089380000
> > 543  test  INFO   [main] openjpa.Runtime - Starting OpenJPA
> 1.3.0-SNAPSHOT
> > 5763  test  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class
> > "org.apache.openjpa.jdbc.sql.MySQLDictionary" (MySQL
> > 5.1.41-ndb-7.1.2-beta-debug ,MySQL-AB JDBC Driver
> > mysql-connector-java-5.1.12 ( Revision: ${bzr.revision-id} )).
> > Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.698
> sec
> >
> > I modified a test case to put the logging information into the setup
> > string and this changed the behavior of the logger.
> >
> >     public void setUp() {
> >         setUp(SQLBigIntegerIdEntity.class
> >                 , "openjpa.Log",
> > "File=openjpaLogger.log,DefaultLevel=INFO,SQL=TRACE,JDBC=TRACE"
> >                 );
> >     }
> >
> > Any ideas why adding properties to the command line or persistence.xml
> > doesn't take effect for tests, but adding the properties to setup does
> > work?
> >
> > Thanks,
> >
> > Craig
> >
> > On Mar 8, 2010, at 2:25 PM, Kevin Sutter wrote:
> >
> >> Hi Craig,
> >> We have found exceptions to the rules, but the order of property
> >> configuration is documented in this section [1] of the manual.  Based on
> >> what you have provided, my guess is that some of your persistence.xml
> >> file(s) are overriding the system properties you are trying to set.
> >>
> >> I don't personally use the system properties, but I would guess you
> >> need to
> >> enclose the values in quotes.  So, I would try that for setting the
> >> openjpa.Log property.
> >>
> >> Good luck!
> >> Kevin
> >>
> >> [1]
> >>
> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_conf_specify
> >>
> >>
> >> On Mon, Mar 8, 2010 at 2:24 PM, Craig L Russell
> >> <Cr...@sun.com>wrote:
> >>
> >>> Hi,
> >>>
> >>> I'm trying to do a few simple things with logging, and having trouble.
> >>>
> >>> 1. Disable WARN messages from the enhancer.
> >>>
> >>> 2. Get SQL TRACE messages.
> >>>
> >>> I've tried unsuccessfully to get either of these to work. I'm using the
> >>> standard OpenJPA logging, and get a few hundred messages out of the
> >>> enhancer, so I know logging is basically working.
> >>>
> >>> Reading everything I can about the logging system, I tried to get the
> >>> enhancer to stop logging WARN but only log ERROR:
> >>>
> >>> -Dopenjpa.Log=none
> >>>
> >>> I still get WARN messages; don't get any errors from the logging
> >>> system; it
> >>> looks like the enhancer is just ignoring this setting
> >>>
> >>> -Dopenjpa.Log=SQL=TRACE,File=openjpaLogger.log
> >>>
> >>> I get output sent to openjpaLogger.log file as expected, but nothing of
> >>> interest. Just:
> >>>
> >>> 11  TRACE  [main] openjpa.Runtime - Default configuration information
> >>> couldn't be loaded from any configuration provider.0  TRACE  [main]
> >>> openjpa.Runtime - Default configuration information couldn't be
> >>> loaded from
> >>> any configuration provider.
> >>> 17  WARN   [main] openjpa.Runtime - The configuration property named
> >>> "openjpa.LogLevel" was not recognized and will be ignored, although
> >>> the name
> >>> closely matches a valid property called "openjpa.Log".
> >>> 17  TRACE  [main] openjpa.Runtime - Default configuration information
> >>> couldn't be loaded from any configuration provider.
> >>> 2  WARN   [main] openjpa.Runtime - The configuration property named
> >>> "openjpa.LogLevel" was not recognized and will be ignored, although
> >>> the name
> >>> closely matches a valid property called "openjpa.Log".
> >>> 2  TRACE  [main] openjpa.Runtime - Default configuration information
> >>> couldn't be loaded from any configuration provider.
> >>> 10  TRACE  [main] openjpa.Runtime - Default configuration information
> >>> couldn't be loaded from any configuration provider.
> >>>
> >>> And where did it get the LogLevel? I didn't set this property!
> >>>
> >>> Can anyone point me in the right direction? Is the -Dopenjpa.Log
> >>> useful for
> >>> anything or do I have to use persistence.xml properties (I haven't
> tried
> >>> this since there are hundreds of persistence.xml files that I would
> >>> need to
> >>> fiddle).
> >>>
> >>> Thanks,
> >>>
> >>> Craig
> >>>
> >>> Craig L Russell
> >>> Architect, Sun Java Enterprise System http://db.apache.org/jdo
> >>> 408 276-5638 mailto:Craig.Russell@sun.com
> >>> P.S. A good JDO? O, Gasp!
> >>>
> >>>
> >
> > Craig L Russell
> > Architect, Sun Java Enterprise System http://db.apache.org/jdo
> > 408 276-5638 mailto:Craig.Russell@sun.com
> > P.S. A good JDO? O, Gasp!
> >
> >
>

Re: Logging settings

Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Donald,

On Mar 9, 2010, at 6:11 AM, Donald Woods wrote:

> Are these junit 3.x tests?  Running under surefire?

Yes.
>
> I run the standard junits as part of trunk builds all the time and  
> turn
> off most of the logging (as I get tired of seeing all those  
> enhancement
> warnings too), by using cmdline options -
>
> 	mvn clean install -Dopenjpa.loglevel=ERROR

This does actually affect the enhancer but it doesn't affect the test  
runs.
>
> The above definitely turns off everything but ERROR messages.
> But, our pom.xml has special setups in them, like providing a  
> default of -
>    <openjpa.loglevel>INFO</openjpa.loglevel>
>
> and then passing them to surefire as -
>    <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-surefire-plugin</artifactId>
>        <configuration>
>            <argLine>${surefire.jvm.args}</argLine>
>            <systemProperties>
>                <property>
>                    <name>openjpa.Log</name>
>                    <value>DefaultLevel=${openjpa.loglevel</value>

This is what kills the properties set on the command line. When I  
change the above line to:

                            <value>DefaultLevel=${openjpa.loglevel},$ 
{openjpa.Log}</value>

all of the command line parameters take effect, and they are processed  
*after* the default level is processed.

I'll propose a patch for this, since as it is now, command line levels  
are disabled when running under surefire.

I'm going to see if this also allows the customization in  
persistence.xml also, but for my purposes the command line is all I  
need.

Thanks for the analysis.

Craig
>                 </property>
>        . . .
>
> The enhancer.xml ANT script gets "openjpa.loglevel" passed in and then
> it remaps it to the expected settings as above.
>
> A couple months back we had a Geronimo user asking about OpenJPA  
> logging
> and they were able to configure custom loglevel and Log file output in
> their persistence.xml using the 1.2.1 level without problems, so it
> should be doable.....
>
>
> -Donald
>
>
> On 3/9/10 1:21 AM, Craig L Russell wrote:
>> Hi Kevin,
>>
>> I did a little more experimentation. There are two persistence  
>> units in
>> the persistence.xml: xml-persistence-unit and test.
>>
>> I can override the settings of the xml-persistence-unit on the  
>> command
>> line.
>>
>> So the settings for File, DefaultLevel, Tool, Enhance, MetaData are  
>> all
>> getting set properly for enhancement.
>>
>> But the log settings I put into the persistence unit test are not  
>> taking
>> effect properly. To verify that I'm using the right persistence  
>> unit, I
>> deliberately caused an error and the error was reported.
>>
>> But even with setting openjpa.Log in the persistence unit, I still  
>> get
>> console logging:
>>
>> Running org.apache.openjpa.persistence.identity.TestSQLBigIntegerId
>> TestSQLBigIntegerId 1268089380000
>> 543  test  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.3.0- 
>> SNAPSHOT
>> 5763  test  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class
>> "org.apache.openjpa.jdbc.sql.MySQLDictionary" (MySQL
>> 5.1.41-ndb-7.1.2-beta-debug ,MySQL-AB JDBC Driver
>> mysql-connector-java-5.1.12 ( Revision: ${bzr.revision-id} )).
>> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:  
>> 10.698 sec
>>
>> I modified a test case to put the logging information into the setup
>> string and this changed the behavior of the logger.
>>
>>    public void setUp() {
>>        setUp(SQLBigIntegerIdEntity.class
>>                , "openjpa.Log",
>> "File=openjpaLogger.log,DefaultLevel=INFO,SQL=TRACE,JDBC=TRACE"
>>                );
>>    }
>>
>> Any ideas why adding properties to the command line or  
>> persistence.xml
>> doesn't take effect for tests, but adding the properties to setup  
>> does
>> work?
>>
>> Thanks,
>>
>> Craig
>>
>> On Mar 8, 2010, at 2:25 PM, Kevin Sutter wrote:
>>
>>> Hi Craig,
>>> We have found exceptions to the rules, but the order of property
>>> configuration is documented in this section [1] of the manual.   
>>> Based on
>>> what you have provided, my guess is that some of your  
>>> persistence.xml
>>> file(s) are overriding the system properties you are trying to set.
>>>
>>> I don't personally use the system properties, but I would guess you
>>> need to
>>> enclose the values in quotes.  So, I would try that for setting the
>>> openjpa.Log property.
>>>
>>> Good luck!
>>> Kevin
>>>
>>> [1]
>>> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_conf_specify
>>>
>>>
>>> On Mon, Mar 8, 2010 at 2:24 PM, Craig L Russell
>>> <Cr...@sun.com>wrote:
>>>
>>>> Hi,
>>>>
>>>> I'm trying to do a few simple things with logging, and having  
>>>> trouble.
>>>>
>>>> 1. Disable WARN messages from the enhancer.
>>>>
>>>> 2. Get SQL TRACE messages.
>>>>
>>>> I've tried unsuccessfully to get either of these to work. I'm  
>>>> using the
>>>> standard OpenJPA logging, and get a few hundred messages out of the
>>>> enhancer, so I know logging is basically working.
>>>>
>>>> Reading everything I can about the logging system, I tried to get  
>>>> the
>>>> enhancer to stop logging WARN but only log ERROR:
>>>>
>>>> -Dopenjpa.Log=none
>>>>
>>>> I still get WARN messages; don't get any errors from the logging
>>>> system; it
>>>> looks like the enhancer is just ignoring this setting
>>>>
>>>> -Dopenjpa.Log=SQL=TRACE,File=openjpaLogger.log
>>>>
>>>> I get output sent to openjpaLogger.log file as expected, but  
>>>> nothing of
>>>> interest. Just:
>>>>
>>>> 11  TRACE  [main] openjpa.Runtime - Default configuration  
>>>> information
>>>> couldn't be loaded from any configuration provider.0  TRACE  [main]
>>>> openjpa.Runtime - Default configuration information couldn't be
>>>> loaded from
>>>> any configuration provider.
>>>> 17  WARN   [main] openjpa.Runtime - The configuration property  
>>>> named
>>>> "openjpa.LogLevel" was not recognized and will be ignored, although
>>>> the name
>>>> closely matches a valid property called "openjpa.Log".
>>>> 17  TRACE  [main] openjpa.Runtime - Default configuration  
>>>> information
>>>> couldn't be loaded from any configuration provider.
>>>> 2  WARN   [main] openjpa.Runtime - The configuration property named
>>>> "openjpa.LogLevel" was not recognized and will be ignored, although
>>>> the name
>>>> closely matches a valid property called "openjpa.Log".
>>>> 2  TRACE  [main] openjpa.Runtime - Default configuration  
>>>> information
>>>> couldn't be loaded from any configuration provider.
>>>> 10  TRACE  [main] openjpa.Runtime - Default configuration  
>>>> information
>>>> couldn't be loaded from any configuration provider.
>>>>
>>>> And where did it get the LogLevel? I didn't set this property!
>>>>
>>>> Can anyone point me in the right direction? Is the -Dopenjpa.Log
>>>> useful for
>>>> anything or do I have to use persistence.xml properties (I  
>>>> haven't tried
>>>> this since there are hundreds of persistence.xml files that I would
>>>> need to
>>>> fiddle).
>>>>
>>>> Thanks,
>>>>
>>>> Craig
>>>>
>>>> Craig L Russell
>>>> Architect, Sun Java Enterprise System http://db.apache.org/jdo
>>>> 408 276-5638 mailto:Craig.Russell@sun.com
>>>> P.S. A good JDO? O, Gasp!
>>>>
>>>>
>>
>> Craig L Russell
>> Architect, Sun Java Enterprise System http://db.apache.org/jdo
>> 408 276-5638 mailto:Craig.Russell@sun.com
>> P.S. A good JDO? O, Gasp!
>>
>>

Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Logging settings

Posted by Donald Woods <dw...@apache.org>.
Are these junit 3.x tests?  Running under surefire?

I run the standard junits as part of trunk builds all the time and turn
off most of the logging (as I get tired of seeing all those enhancement
warnings too), by using cmdline options -

	mvn clean install -Dopenjpa.loglevel=ERROR

The above definitely turns off everything but ERROR messages.
But, our pom.xml has special setups in them, like providing a default of -
    <openjpa.loglevel>INFO</openjpa.loglevel>

and then passing them to surefire as -
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <argLine>${surefire.jvm.args}</argLine>
            <systemProperties>
                <property>
                    <name>openjpa.Log</name>
                    <value>DefaultLevel=${openjpa.loglevel</value>
                </property>
        . . .

The enhancer.xml ANT script gets "openjpa.loglevel" passed in and then
it remaps it to the expected settings as above.

A couple months back we had a Geronimo user asking about OpenJPA logging
and they were able to configure custom loglevel and Log file output in
their persistence.xml using the 1.2.1 level without problems, so it
should be doable.....


-Donald


On 3/9/10 1:21 AM, Craig L Russell wrote:
> Hi Kevin,
> 
> I did a little more experimentation. There are two persistence units in
> the persistence.xml: xml-persistence-unit and test.
> 
> I can override the settings of the xml-persistence-unit on the command
> line.
> 
> So the settings for File, DefaultLevel, Tool, Enhance, MetaData are all
> getting set properly for enhancement.
> 
> But the log settings I put into the persistence unit test are not taking
> effect properly. To verify that I'm using the right persistence unit, I
> deliberately caused an error and the error was reported.
> 
> But even with setting openjpa.Log in the persistence unit, I still get
> console logging:
> 
> Running org.apache.openjpa.persistence.identity.TestSQLBigIntegerId
> TestSQLBigIntegerId 1268089380000
> 543  test  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.3.0-SNAPSHOT
> 5763  test  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class
> "org.apache.openjpa.jdbc.sql.MySQLDictionary" (MySQL
> 5.1.41-ndb-7.1.2-beta-debug ,MySQL-AB JDBC Driver
> mysql-connector-java-5.1.12 ( Revision: ${bzr.revision-id} )).
> Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.698 sec
> 
> I modified a test case to put the logging information into the setup
> string and this changed the behavior of the logger.
> 
>     public void setUp() {
>         setUp(SQLBigIntegerIdEntity.class
>                 , "openjpa.Log",
> "File=openjpaLogger.log,DefaultLevel=INFO,SQL=TRACE,JDBC=TRACE"
>                 );
>     }
> 
> Any ideas why adding properties to the command line or persistence.xml
> doesn't take effect for tests, but adding the properties to setup does
> work?
> 
> Thanks,
> 
> Craig
> 
> On Mar 8, 2010, at 2:25 PM, Kevin Sutter wrote:
> 
>> Hi Craig,
>> We have found exceptions to the rules, but the order of property
>> configuration is documented in this section [1] of the manual.  Based on
>> what you have provided, my guess is that some of your persistence.xml
>> file(s) are overriding the system properties you are trying to set.
>>
>> I don't personally use the system properties, but I would guess you
>> need to
>> enclose the values in quotes.  So, I would try that for setting the
>> openjpa.Log property.
>>
>> Good luck!
>> Kevin
>>
>> [1]
>> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_conf_specify
>>
>>
>> On Mon, Mar 8, 2010 at 2:24 PM, Craig L Russell
>> <Cr...@sun.com>wrote:
>>
>>> Hi,
>>>
>>> I'm trying to do a few simple things with logging, and having trouble.
>>>
>>> 1. Disable WARN messages from the enhancer.
>>>
>>> 2. Get SQL TRACE messages.
>>>
>>> I've tried unsuccessfully to get either of these to work. I'm using the
>>> standard OpenJPA logging, and get a few hundred messages out of the
>>> enhancer, so I know logging is basically working.
>>>
>>> Reading everything I can about the logging system, I tried to get the
>>> enhancer to stop logging WARN but only log ERROR:
>>>
>>> -Dopenjpa.Log=none
>>>
>>> I still get WARN messages; don't get any errors from the logging
>>> system; it
>>> looks like the enhancer is just ignoring this setting
>>>
>>> -Dopenjpa.Log=SQL=TRACE,File=openjpaLogger.log
>>>
>>> I get output sent to openjpaLogger.log file as expected, but nothing of
>>> interest. Just:
>>>
>>> 11  TRACE  [main] openjpa.Runtime - Default configuration information
>>> couldn't be loaded from any configuration provider.0  TRACE  [main]
>>> openjpa.Runtime - Default configuration information couldn't be
>>> loaded from
>>> any configuration provider.
>>> 17  WARN   [main] openjpa.Runtime - The configuration property named
>>> "openjpa.LogLevel" was not recognized and will be ignored, although
>>> the name
>>> closely matches a valid property called "openjpa.Log".
>>> 17  TRACE  [main] openjpa.Runtime - Default configuration information
>>> couldn't be loaded from any configuration provider.
>>> 2  WARN   [main] openjpa.Runtime - The configuration property named
>>> "openjpa.LogLevel" was not recognized and will be ignored, although
>>> the name
>>> closely matches a valid property called "openjpa.Log".
>>> 2  TRACE  [main] openjpa.Runtime - Default configuration information
>>> couldn't be loaded from any configuration provider.
>>> 10  TRACE  [main] openjpa.Runtime - Default configuration information
>>> couldn't be loaded from any configuration provider.
>>>
>>> And where did it get the LogLevel? I didn't set this property!
>>>
>>> Can anyone point me in the right direction? Is the -Dopenjpa.Log
>>> useful for
>>> anything or do I have to use persistence.xml properties (I haven't tried
>>> this since there are hundreds of persistence.xml files that I would
>>> need to
>>> fiddle).
>>>
>>> Thanks,
>>>
>>> Craig
>>>
>>> Craig L Russell
>>> Architect, Sun Java Enterprise System http://db.apache.org/jdo
>>> 408 276-5638 mailto:Craig.Russell@sun.com
>>> P.S. A good JDO? O, Gasp!
>>>
>>>
> 
> Craig L Russell
> Architect, Sun Java Enterprise System http://db.apache.org/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com
> P.S. A good JDO? O, Gasp!
> 
> 

Re: Logging settings

Posted by Craig L Russell <Cr...@SUN.com>.
Hi Kevin,

I did a little more experimentation. There are two persistence units  
in the persistence.xml: xml-persistence-unit and test.

I can override the settings of the xml-persistence-unit on the command  
line.

So the settings for File, DefaultLevel, Tool, Enhance, MetaData are  
all getting set properly for enhancement.

But the log settings I put into the persistence unit test are not  
taking effect properly. To verify that I'm using the right persistence  
unit, I deliberately caused an error and the error was reported.

But even with setting openjpa.Log in the persistence unit, I still get  
console logging:

Running org.apache.openjpa.persistence.identity.TestSQLBigIntegerId
TestSQLBigIntegerId 1268089380000
543  test  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.3.0- 
SNAPSHOT
5763  test  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class  
"org.apache.openjpa.jdbc.sql.MySQLDictionary" (MySQL 5.1.41-ndb-7.1.2- 
beta-debug ,MySQL-AB JDBC Driver mysql-connector-java-5.1.12  
( Revision: ${bzr.revision-id} )).
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.698  
sec

I modified a test case to put the logging information into the setup  
string and this changed the behavior of the logger.

     public void setUp() {
         setUp(SQLBigIntegerIdEntity.class
                 , "openjpa.Log",  
"File=openjpaLogger.log,DefaultLevel=INFO,SQL=TRACE,JDBC=TRACE"
                 );
     }

Any ideas why adding properties to the command line or persistence.xml  
doesn't take effect for tests, but adding the properties to setup does  
work?

Thanks,

Craig

On Mar 8, 2010, at 2:25 PM, Kevin Sutter wrote:

> Hi Craig,
> We have found exceptions to the rules, but the order of property
> configuration is documented in this section [1] of the manual.   
> Based on
> what you have provided, my guess is that some of your persistence.xml
> file(s) are overriding the system properties you are trying to set.
>
> I don't personally use the system properties, but I would guess you  
> need to
> enclose the values in quotes.  So, I would try that for setting the
> openjpa.Log property.
>
> Good luck!
> Kevin
>
> [1]
> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_conf_specify
>
> On Mon, Mar 8, 2010 at 2:24 PM, Craig L Russell  
> <Cr...@sun.com>wrote:
>
>> Hi,
>>
>> I'm trying to do a few simple things with logging, and having  
>> trouble.
>>
>> 1. Disable WARN messages from the enhancer.
>>
>> 2. Get SQL TRACE messages.
>>
>> I've tried unsuccessfully to get either of these to work. I'm using  
>> the
>> standard OpenJPA logging, and get a few hundred messages out of the
>> enhancer, so I know logging is basically working.
>>
>> Reading everything I can about the logging system, I tried to get the
>> enhancer to stop logging WARN but only log ERROR:
>>
>> -Dopenjpa.Log=none
>>
>> I still get WARN messages; don't get any errors from the logging  
>> system; it
>> looks like the enhancer is just ignoring this setting
>>
>> -Dopenjpa.Log=SQL=TRACE,File=openjpaLogger.log
>>
>> I get output sent to openjpaLogger.log file as expected, but  
>> nothing of
>> interest. Just:
>>
>> 11  TRACE  [main] openjpa.Runtime - Default configuration information
>> couldn't be loaded from any configuration provider.0  TRACE  [main]
>> openjpa.Runtime - Default configuration information couldn't be  
>> loaded from
>> any configuration provider.
>> 17  WARN   [main] openjpa.Runtime - The configuration property named
>> "openjpa.LogLevel" was not recognized and will be ignored, although  
>> the name
>> closely matches a valid property called "openjpa.Log".
>> 17  TRACE  [main] openjpa.Runtime - Default configuration information
>> couldn't be loaded from any configuration provider.
>> 2  WARN   [main] openjpa.Runtime - The configuration property named
>> "openjpa.LogLevel" was not recognized and will be ignored, although  
>> the name
>> closely matches a valid property called "openjpa.Log".
>> 2  TRACE  [main] openjpa.Runtime - Default configuration information
>> couldn't be loaded from any configuration provider.
>> 10  TRACE  [main] openjpa.Runtime - Default configuration information
>> couldn't be loaded from any configuration provider.
>>
>> And where did it get the LogLevel? I didn't set this property!
>>
>> Can anyone point me in the right direction? Is the -Dopenjpa.Log  
>> useful for
>> anything or do I have to use persistence.xml properties (I haven't  
>> tried
>> this since there are hundreds of persistence.xml files that I would  
>> need to
>> fiddle).
>>
>> Thanks,
>>
>> Craig
>>
>> Craig L Russell
>> Architect, Sun Java Enterprise System http://db.apache.org/jdo
>> 408 276-5638 mailto:Craig.Russell@sun.com
>> P.S. A good JDO? O, Gasp!
>>
>>

Craig L Russell
Architect, Sun Java Enterprise System http://db.apache.org/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Logging settings

Posted by Kevin Sutter <kw...@gmail.com>.
Hi Craig,
We have found exceptions to the rules, but the order of property
configuration is documented in this section [1] of the manual.  Based on
what you have provided, my guess is that some of your persistence.xml
file(s) are overriding the system properties you are trying to set.

I don't personally use the system properties, but I would guess you need to
enclose the values in quotes.  So, I would try that for setting the
openjpa.Log property.

Good luck!
Kevin

[1]
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_conf_specify

On Mon, Mar 8, 2010 at 2:24 PM, Craig L Russell <Cr...@sun.com>wrote:

> Hi,
>
> I'm trying to do a few simple things with logging, and having trouble.
>
> 1. Disable WARN messages from the enhancer.
>
> 2. Get SQL TRACE messages.
>
> I've tried unsuccessfully to get either of these to work. I'm using the
> standard OpenJPA logging, and get a few hundred messages out of the
> enhancer, so I know logging is basically working.
>
> Reading everything I can about the logging system, I tried to get the
> enhancer to stop logging WARN but only log ERROR:
>
> -Dopenjpa.Log=none
>
> I still get WARN messages; don't get any errors from the logging system; it
> looks like the enhancer is just ignoring this setting
>
> -Dopenjpa.Log=SQL=TRACE,File=openjpaLogger.log
>
> I get output sent to openjpaLogger.log file as expected, but nothing of
> interest. Just:
>
> 11  TRACE  [main] openjpa.Runtime - Default configuration information
> couldn't be loaded from any configuration provider.0  TRACE  [main]
> openjpa.Runtime - Default configuration information couldn't be loaded from
> any configuration provider.
> 17  WARN   [main] openjpa.Runtime - The configuration property named
> "openjpa.LogLevel" was not recognized and will be ignored, although the name
> closely matches a valid property called "openjpa.Log".
> 17  TRACE  [main] openjpa.Runtime - Default configuration information
> couldn't be loaded from any configuration provider.
> 2  WARN   [main] openjpa.Runtime - The configuration property named
> "openjpa.LogLevel" was not recognized and will be ignored, although the name
> closely matches a valid property called "openjpa.Log".
> 2  TRACE  [main] openjpa.Runtime - Default configuration information
> couldn't be loaded from any configuration provider.
> 10  TRACE  [main] openjpa.Runtime - Default configuration information
> couldn't be loaded from any configuration provider.
>
> And where did it get the LogLevel? I didn't set this property!
>
> Can anyone point me in the right direction? Is the -Dopenjpa.Log useful for
> anything or do I have to use persistence.xml properties (I haven't tried
> this since there are hundreds of persistence.xml files that I would need to
> fiddle).
>
> Thanks,
>
> Craig
>
> Craig L Russell
> Architect, Sun Java Enterprise System http://db.apache.org/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com
> P.S. A good JDO? O, Gasp!
>
>