Wednesday, March 31, 2021

sql logging for jsf application in netbeans

To enable SQL logging to the netbeans console for a JSF application running in Payara with EclipseLink, add the following properties to the persistence.xml file: 
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.logging.logger" value="DefaultLogger"/>
More information here and here.

On a related note, logging can also be enabled directly in mysql, if that's the underlying database.  Here are some notes about doing that:

log in to mysql as root:
-> use mysql; 
-> SET global log_output = 'table'; 
-> SET GLOBAL general_log = 1;
then you can see the logged statements using:
select * from general_log;

or count the number of sql statements:
select count(*) from general_log; 
and clean it up with:
truncate general_log; 

No comments: