Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Monitoring EclipseLink JPA progress

I'm back at my first EclipseLink JPA project and noticed some issues regarding the performance. Here's the situation:

The application runs with a local Apache Derby DB. During the creation of the EntityManager the console logs a few infos and warnings, which takes a few seconds but is fine so far. However, if I package the whole code into an executable jar and run it outside Eclipse, the whole process takes a lot more time.

Now while it would be wise to find the reason for this issues in the first place, I at least wanted to add a ProgressBar in order keep rough track of the progress.

I looked up the EclipseLink wiki and found out that it already features a PerformanceMonitor and some logging utilities. I am now stuck at the seemingly simple task of putting 1 and 1 together.

How can I hook up my ProgressBar with EclipseLink? Or another approach: How can I log ongoing activities of EclipseLink in the first place?

Any help is much appreciated.

Cheers

like image 443
The-Stig Avatar asked Sep 05 '26 13:09

The-Stig


1 Answers

Here is the steps to produce a log file for an SE project (non-application server one) which has EclipseLink JPA:

  1. Open the file "persistence.xml" and assign the following properties:

    property name="eclipselink.logging.logger" value="JavaLogger"

    property name="eclipselink.logging.level" value="FINEST"

  2. Given that Eclipselink JavaLogger is in fact a java.util.logging one, refer to your JDK folder to locate the file logging.properties which is to be modified as follows:

handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler

# Default global logging level.

.level= FINEST

# default file output is in user's home directory

# java.util.logging.FileHandler.pattern = %h/java%u.log

# but I prefer to hard wire it as follows:

java.util.logging.FileHandler.pattern = C\:/SamLogFile.log

java.util.logging.FileHandler.level = FINER

java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

# I personally don't care about the stdout logging, so I turn it off.

java.util.logging.ConsoleHandler.level = OFF

java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n

Now you can place some logging within your class by importing:

import java.util.logging.Level;

import java.util.logging.Logger;

And calling:

public void yourMethod() { 

Logger.getLogger( YourClassName.class.getName() ).log( Level.INFO, "I am logging well......!" ); }

Now you are set. Run/test your project and enjoy reading your log!

like image 193
Sym-Sym Avatar answered Sep 08 '26 03:09

Sym-Sym



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!