Permalink
Browse files

fix:Do not set the loglevel when instantiating a connection it is set…

… when the Driver starts
  • Loading branch information...
davecramer committed Oct 24, 2015
1 parent 004e43b commit 84b28eb9f450f844d375a427816ef1758ff66b18
Showing with 0 additions and 19 deletions.
  1. +0 −19 org/postgresql/jdbc2/AbstractJdbc2Connection.java
@@ -127,19 +127,12 @@ protected AbstractJdbc2Connection(HostSpec[] hostSpecs, String user, String data
// standard out if no other printwriter is set

int logLevel = Driver.getLogLevel();
Integer connectionLogLevel = PGProperty.LOG_LEVEL.getInteger(info);

This comment has been minimized.

@whitingjr

whitingjr Dec 1, 2015

Contributor

Removing this line causes all debug logging to be turned off when using a DataSource. This makes low level debugging far more difficult.
What is being fixed by this line being removed ?

This comment has been minimized.

@davecramer

davecramer Dec 1, 2015

Member

Ah, right, now I recall. If you do something like org.postgresql.Driver.setLogLevel. this line reverts that change unless you have the property externally set as per your DataSource configuration

if (connectionLogLevel != null) {
logLevel = connectionLogLevel;
}

synchronized (AbstractJdbc2Connection.class) {
logger = new Logger(nextConnectionID++);
logger.setLogLevel(logLevel);
}

if (logLevel > 0)
enableDriverManagerLogging();

This comment has been minimized.

@whitingjr

whitingjr Dec 8, 2015

Contributor

with this line removed the DriverManager.logWriter object is always null. which disables info/debug logging.
Did you intend to replace this line with something else to set up logging ?


setDefaultFetchSize(PGProperty.DEFAULT_ROW_FETCH_SIZE.getInt(info));

prepareThreshold = PGProperty.PREPARE_THRESHOLD.getInt(info);
@@ -272,7 +265,6 @@ else if (stringType.equalsIgnoreCase("varchar"))

if (PGProperty.LOG_UNCLOSED_CONNECTIONS.getBoolean(info)) {
openStackTrace = new Throwable("Connection was created at this point:");
enableDriverManagerLogging();
}
this.disableColumnSanitiser = PGProperty.DISABLE_COLUMN_SANITISER.getBoolean(info);
statementCache = new LruCache<Object, CachedQuery>(
@@ -1285,17 +1277,6 @@ public Logger getLogger()
}


//Because the get/setLogStream methods are deprecated in JDBC2
//we use the get/setLogWriter methods here for JDBC2 by overriding
//the base version of this method
protected void enableDriverManagerLogging()
{
if (DriverManager.getLogWriter() == null)
{
DriverManager.setLogWriter(new PrintWriter(System.out, true));
}
}

public int getProtocolVersion()
{
return protoConnection.getProtocolVersion();

1 comment on commit 84b28eb

@davecramer

This comment has been minimized.

Member

davecramer commented on 84b28eb Dec 1, 2015

Interesting catch-22 it caused debugging to be turned off when not using a DataSource

Please sign in to comment.