Activating Logging

To enable logging in Oracle NoSQL Database SDK for Spring Data, you must include the following parameter when running the application.

-Dlogging.level.com.oracle.nosql.spring.data=DEBUG
The following are the logging levels that you could provide:
  • ERROR: The ERROR level logging includes any unexpected errors.
  • DEBUG: The DEBUG level logging includes generated SQL statements that the module generates internally.

The following example contains the code to run the application with logging.

# To run the application with Nosql module logging at DEBUG level
$ java -cp $CP:target/example-spring-data-oracle-nosql-1.3-SNAPSHOT.jar   
    -Dlogging.level.com.oracle.nosql.spring.data=DEBUG org.example.App
...
020-12-02 11:50:18.426 DEBUG 20325 --- [ main]
    c.o.n.spring.data.core.NosqlTemplate : DDL: CREATE TABLE IF NOT EXISTS
        StudentTable (id LONG GENERATED ALWAYS as IDENTITY (NO CYCLE),
        kv_json_ JSON, PRIMARY KEY( id ))
2020-12-02 11:50:19.334 INFO 20325 --- [ main]
    org.example.App : Started App in 2.464 seconds (JVM running for 2.782)
=== Start of App ====
2020-12-02 11:50:19.340 DEBUG 20325 --- [ main]
    c.o.n.spring.data.core.NosqlTemplate : Q: DELETE FROM StudentTable
Saving s1: Student{id=0, firstName='John', lastName='Doe'}
2020-12-02 11:50:19.362 DEBUG 20325 --- [ main]
    c.o.n.spring.data.core.NosqlTemplate : execute insert in table StudentTable
Saving s2: Student{id=0, firstName='John', lastName='Smith'}
2020-12-02 11:50:19.387 DEBUG 20325 --- [ main]
    c.o.n.spring.data.core.NosqlTemplate : execute insert in table StudentTable
 
findAll:
2020-12-02 11:50:19.392 DEBUG 20325 --- [ main]
    c.o.n.spring.data.core.NosqlTemplate : Q: SELECT * FROM StudentTable t
Student: Student{id=1, firstName='John', lastName='Doe'}
Student: Student{id=2, firstName='John', lastName='Smith'}
 
findByLastName: Smith
2020-12-02 11:50:19.412 DEBUG 20325 --- [ main]
    c.o.n.spring.data.core.NosqlTemplate : Q: declare $p_lastName String;
        select * from StudentTable as t where t.kv_json_.lastName = $p_lastName
Student: Student{id=2, firstName='John', lastName='Smith'}
2020-12-02 11:50:19.426 DEBUG 20325 --- [ main]
    c.o.n.spring.data.core.NosqlTemplate : DDL: DROP TABLE IF EXISTS StudentTable
=== End of App ====
 
# To enable Nosql module logging when running tests
$ mvn test -Dlogging.level.com.oracle.nosql.spring.data=DEBUG
...

You can enable additional logging and client statistics at the NoSQL Java SDK level. For more details, see Logging in the SDK and Logging internal SDK statistics in the oracle.nosql.driver package.