Unable to locate c3p0 logging messages - java

Up until recently, we created a new database connection for every query. Each query is setup using connection.prepareStatement(query) and we were able to log these queries to our logger (java.util.logging) with preparedStatement.toString(). This was using the postgresql JDBC driver.
Now we've switched to using c3p0 to manage connection pools and unfortunately preparedStatement.toString() no longer returns the prepared query statement.
I have read that c3p0 logging can be directed to the standard logging facility but unfortunately I have been unable to find where these messages are going. Where can I find these messages? Glassfish 3's console in NetBeans states that debugging is enabled.
INFO: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]

I'm not sure, if c3p0's logging is what you are really looking for?
I would recommend using log4jdbc, which can log any JDBC queries (with parameters), and even provide you with a stack trace pointing to your JDBC/Hibernate/... statement, even if you're using a connection pool (use the option -Dlog4jdbc.debug.stack.prefix=com.mycompany.myapp). It can also display timing information, and a lot more.

The logging seems to be on like the log says (debug?true), but if you read the box on the link you had on your post you will find the setup options that should be checked for finding the right file.
If you end up logging to the so called last resort option, it should log to System.Err and this may cause the problem: this post tells that System.Err is not by default always visible in any log file!
So keep trying the other options on the previously mentioned box or use the fix on the answer section of the post I linked :)

Related

Upgrading to hibernate 6: Encountered deprecated setting [javax.persistence.lock.timeout], use [jakarta.persistence.lock.timeout] instead

I am trying to upgrade to Hibernate 6, but this causes a huge amount of log spam. For every query with my database I get a warning in my console logs:
WARN deprecation:44 - HHH90000021:
Encountered deprecated setting [javax.persistence.lock.timeout], use [jakarta.persistence.lock.timeout] instead
Our code base does not reference javax.persistence.lock.timeout and setting the jakarta property into the peristence.xml file does nothing.
This issue doesn't seem to be documented on the internet, I could only find a single reference to this in a hibernate bug report team, but there are no details.
If its relevant, we are connecting to Postgres on AWS RDS, via the C3P0 connection pool.
This warning continues to appear after removing C3P0 from the server so I don't think this default is coming from there.
Should I just suppress this log source in my log properties file or are there alternatives others are following?
I also experienced the same issue. And it seems not to be fixed yet(in 6.0.1).
At least I see in https://github.com/hibernate/hibernate-orm/blob/c18e611ed6786fd62a6bf2d17c39589c2452fe35/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java that old (and deprecated) javax.* properties are still set and then logged by LegacySpecHelper:
p.putIfAbsent( AvailableSettings.FLUSH_MODE, FlushMode.AUTO.name() );
p.putIfAbsent( JPA_LOCK_SCOPE, PessimisticLockScope.EXTENDED.name() );
p.putIfAbsent( JAKARTA_LOCK_SCOPE, PessimisticLockScope.EXTENDED.name() );
p.putIfAbsent( JPA_LOCK_TIMEOUT, LockOptions.WAIT_FOREVER );
According to HHH-15768 it is going to be fixed in Hibernate 6.1.7.
A temporary workaround is to set the property explicitly (accepted modes are defined here):
spring.jpa.properties.jakarta.persistence.sharedCache.mode=ENABLE_SELECTIVE
More on the problem and the workaround - here

Spring Webflux - logging connection ID and new Connection log not displayed when using Webflux webclient

Many tutorials online are pointing out the importance of having connection ID in a Spring Webflux application.
For instance, see this screenshot taken from a presentation in a conference.
However, I am not getting those IDs. I can only see the part with the time, up until the [ctor-http-nio5].
I cannot see the connection ID, I cannot see the statement "New http connection"
What can be the root cause of me not being able to display such? I really would like to see those interesting logs.
Thank you for your help
This ID is unique for each of the connections made to your server and you can extract it by calling the getLogPrefix() method of ServerWebExchange class and can append it to your logs by directly or by putting it to the MDC.
By default spring framework logs this id in the framework logs.
These framework logs are at the DEBUG level so you need to enable debug level to see the logs with ids.
By adding the following configuration to the application.properties you can see the logs with ids.
logging.level.org.springframework=DEBUG

Get messages.log style logging out of embedded neo4j

How can I maximize the log information an embedded neo4j database will give me, so that I can see what's going on?
Recent technical discussion on the google group called for an excerpt of messages.log, but I don't have that log file since I'm running embedded. I have consulted the server configuration docs (http://docs.neo4j.org/chunked/stable/server-configuration.html#_server_logging_configuration) but they don't tell me the actual names of the loggers to use.
I have tried this:
java.util.logging.Logger.getLogger("org.neo4j").setLevel(Level.ALL)
But by default, and also with this line of code, I see no log messages from neo4j at all.
I'm trying to get some of the server message logs to debug why certain read-only transactions are failing and rollback is failing; first I have to figure out how to get neo4j to tell me what's going on in this embedded database.
Actually you have messages.log it is in your graph.db directory.
And there are loads of diagnostic, config, tuning, memory and other information in that file. So very valuable.

Intercept JDBC Connection

I've a superclass that have a java.sql.Connection. There are a lot of subclasses that uses the connection to execute selects.
I need to intercept all statements executed through the connection, and log the executed SQL.
How can I do it?
Use log4jdbc. It's a proxying JDBC driver that logs all your SQL and passes the SQL and parameters on to the underlying driver. That way your code doesn't even have to be aware of the logging, it's all contained within the third-party library.
The configuration consists mostly of changing your JDBC connection string to use the proxy instead of the real driver, and telling log4jdbc what the real JDBC driver is. Then you pick logging categories in your log4j configuration to tell what kind of things you want to log. You can get the SQL, timing information, connection opening and closing events, and result set contents.
If you want an in-depth explanation of how it works see Jack Shirazi's book Java Performance Tuning. There's an extended example of building a proxying driver in the chapter on JDBC.

hsqldb messing up with my server´s logs

I have a server I made in Java that needs to use a database, I chose HSQLDB.
So I have a lot of entries in my server like:
Logger.getLogger(getClass().getName()). severe or info ("Some important information");
When I run my server it goes to System.out which I think its the default configuration of java.util.logging?, so far its ok for me, and later I will make it go to a file ...
But, the problem is, when I start hsqldb it messes up with the default configuration and I can´t read my log entries on System.out anymore..
I already tried to change hsqldb.log_data=false, but it still messes up the default configuration.
Can someone help me??
I dont want to log hsqldb events, just my server ones.
Thanks
This issue was reported and fixed in the latest version 2.2.0 released today.
Basically, you set a system property hsqldb.reconfig_logging to the
string value false.
A system property is normally set with the -D option in the Java startup command for your application:
java -Dhsqldb.reconfig_logging=false ....
See below for details of the change:
http://sourceforge.net/tracker/?func=detail&aid=3195462&group_id=23316&atid=378131
In addition, when you use a fremework logger for your application, you should configure it directly to choose which levels of log to accept and which ones to ignore.
The hsqldb.applog setting does not affect framework logging and only controls the file log.
The hsqldb.log_data=false is for turning off internal data change logging and should not be used for normal databases. Its usage for bulk imports is explained in the Guide.
Try setting hsqldb.applog to 0, that shuts off application logging to the *.app.log file.
Start your server with a property pointing to the location of a dedicated properties file:
-Djava.util.logging.config.file=/location/of/your/hsqldblog.properties"
Which contains the following line to change Java logging for Hsqldb.
# Change hsqldb logging level
org.hsqldb.persist = WARNING
Side note, you can choose from the following levels:
SEVERE WARNING INFO CONFIG FINE FINER FINEST

Categories

Resources