From fc67e3d66871ad7fbafdfdaa4330b9300721c1fa Mon Sep 17 00:00:00 2001 From: hieplq Date: Mon, 19 Oct 2015 20:37:01 +0800 Subject: [PATCH] IDEMPIERE-2892:add config let out put log of c3p0 --- .../META-INF/MANIFEST.MF | 3 ++- .../META-INF/pool/server.default.properties | 3 ++- .../src/org/compiere/db/DB_Oracle.java | 16 +++++++++++++++- .../META-INF/MANIFEST.MF | 3 ++- .../META-INF/pool/server.default.properties | 3 ++- .../src/org/compiere/db/DB_PostgreSQL.java | 17 ++++++++++++++++- 6 files changed, 39 insertions(+), 6 deletions(-) diff --git a/org.compiere.db.oracle.provider/META-INF/MANIFEST.MF b/org.compiere.db.oracle.provider/META-INF/MANIFEST.MF index daeed551d8..06b2c197a6 100644 --- a/org.compiere.db.oracle.provider/META-INF/MANIFEST.MF +++ b/org.compiere.db.oracle.provider/META-INF/MANIFEST.MF @@ -11,7 +11,8 @@ Bundle-ClassPath: ., c3p0-0.9.5-pre9.jar, c3p0-oracle-thin-extras-0.9.5-pre9.jar, mchange-commons-java-0.2.8.jar -Import-Package: org.osgi.framework +Import-Package: org.osgi.framework, + org.slf4j;version="1.7.2" Bundle-ActivationPolicy: lazy Bundle-Activator: org.adempiere.db.oracle.OracleBundleActivator Service-Component: OSGI-INF/oracleprovider.xml diff --git a/org.compiere.db.oracle.provider/META-INF/pool/server.default.properties b/org.compiere.db.oracle.provider/META-INF/pool/server.default.properties index 0c08b38d20..06fe7041ee 100644 --- a/org.compiere.db.oracle.provider/META-INF/pool/server.default.properties +++ b/org.compiere.db.oracle.provider/META-INF/pool/server.default.properties @@ -14,4 +14,5 @@ MaxStatementsPerConnection=30 #flag TestConnectionOnCheckin=false TestConnectionOnCheckout=false -#CheckoutTimeout=60; \ No newline at end of file +#CheckoutTimeout=60; +com.mchange.v2.log.MLog=com.mchange.v2.log.slf4j.Slf4jMLog \ No newline at end of file diff --git a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java index 61addf67a7..f6d8c22c18 100644 --- a/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java +++ b/org.compiere.db.oracle.provider/src/org/compiere/db/DB_Oracle.java @@ -661,10 +661,11 @@ public class DB_Oracle implements AdempiereDatabase int unreturnedConnectionTimeout = getIntProperty(poolProperties, "UnreturnedConnectionTimeout", 0); boolean testConnectionOnCheckin = getBooleanProperty(poolProperties, "TestConnectionOnCheckin", false); boolean testConnectionOnCheckout = getBooleanProperty(poolProperties, "TestConnectionOnCheckout", false); + String mlogClass = getStringProperty(poolProperties, "com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog"); int checkoutTimeout = getIntProperty(poolProperties, "CheckoutTimeout", 0); try { - System.setProperty("com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog"); + System.setProperty("com.mchange.v2.log.MLog", mlogClass); //System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "ALL"); ComboPooledDataSource cpds = new ComboPooledDataSource(); cpds.setDataSourceName("iDempiereDS"); @@ -1320,6 +1321,19 @@ public class DB_Oracle implements AdempiereDatabase return b; } + private String getStringProperty(Properties properties, String key, String defaultValue) + { + String b = defaultValue; + try + { + String s = properties.getProperty(key); + if (s != null && s.trim().length() > 0) + b = s.trim(); + } + catch(Exception e){} + return b; + } + @Override public boolean forUpdate(PO po, int timeout) { //only can lock for update if using trx diff --git a/org.compiere.db.postgresql.provider/META-INF/MANIFEST.MF b/org.compiere.db.postgresql.provider/META-INF/MANIFEST.MF index 6c2f088aaa..eef913afce 100644 --- a/org.compiere.db.postgresql.provider/META-INF/MANIFEST.MF +++ b/org.compiere.db.postgresql.provider/META-INF/MANIFEST.MF @@ -12,7 +12,8 @@ Require-Bundle: org.adempiere.base;bundle-version="3.0.0", org.adempiere.install;bundle-version="3.0.0" Import-Package: junit.framework;version="3.8.2", org.junit;version="4.8.1", - org.osgi.framework + org.osgi.framework, + org.slf4j;version="1.7.2" Bundle-ActivationPolicy: lazy Bundle-Activator: org.adempiere.db.postgresql.PostgreSQLBundleActivator Service-Component: OSGI-INF/pgprovider.xml diff --git a/org.compiere.db.postgresql.provider/META-INF/pool/server.default.properties b/org.compiere.db.postgresql.provider/META-INF/pool/server.default.properties index 4224891060..eedc484d31 100644 --- a/org.compiere.db.postgresql.provider/META-INF/pool/server.default.properties +++ b/org.compiere.db.postgresql.provider/META-INF/pool/server.default.properties @@ -15,4 +15,5 @@ MaxStatementsPerConnection=30 #flag TestConnectionOnCheckin=false TestConnectionOnCheckout=false -#CheckoutTimeout=60; \ No newline at end of file +#CheckoutTimeout=60; +com.mchange.v2.log.MLog=com.mchange.v2.log.slf4j.Slf4jMLog \ No newline at end of file diff --git a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java index c08a1cafad..93caefe48a 100755 --- a/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java +++ b/org.compiere.db.postgresql.provider/src/org/compiere/db/DB_PostgreSQL.java @@ -753,11 +753,13 @@ public class DB_PostgreSQL implements AdempiereDatabase int unreturnedConnectionTimeout = getIntProperty(poolProperties, "UnreturnedConnectionTimeout", 0); boolean testConnectionOnCheckin = getBooleanProperty(poolProperties, "TestConnectionOnCheckin", false); boolean testConnectionOnCheckout = getBooleanProperty(poolProperties, "TestConnectionOnCheckout", false); + String mlogClass = getStringProperty(poolProperties, "com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog"); + int checkoutTimeout = getIntProperty(poolProperties, "CheckoutTimeout", 0); try { - System.setProperty("com.mchange.v2.log.MLog", "com.mchange.v2.log.FallbackMLog"); + System.setProperty("com.mchange.v2.log.MLog", mlogClass); //System.setProperty("com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL", "ALL"); ComboPooledDataSource cpds = new ComboPooledDataSource(); cpds.setDataSourceName("iDempiereDS"); @@ -1048,6 +1050,19 @@ public class DB_PostgreSQL implements AdempiereDatabase catch (Exception e) {} return b; } + + private String getStringProperty(Properties properties, String key, String defaultValue) + { + String b = defaultValue; + try + { + String s = properties.getProperty(key); + if (s != null && s.trim().length() > 0) + b = s.trim(); + } + catch (Exception e) {} + return b; + } @Override public boolean forUpdate(PO po, int timeout) {