From: Chen Huajun <chenhj@cn.fujitsu.com>
To: List <pgsql-jdbc@postgresql.org>
Subject: Patch to add a new loglevel(OFF) to turn off logging
Date: Mon, 18 Feb 2013 18:50:52 +0800
Message-ID: <5122078C.90906@cn.fujitsu.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
Hi,
As discussed before, adding a new loglevel explicitly
to turn off logging may be useful sometimes.
For example:
Driver.setLogLevel() ;//open a JVM level's logging
con = DriverManager.getConnection(connectionString)//want to turn off logging in this Connection
or
Driver.setLogLevel() ;//open logging
//do something
Driver.setLogLevel() ;//want to turn off logging
//do other things
And I have wrote a simple patch for that,
Hopefully this useful.
*)if be accepted,document about loglevel should be updated
--
Best Regards,
Chen Huajun
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbcAttachments:pgjdbc_new_loglevel_OFF.patch (text/plain, 1.9K) downloaddiff --git a/org/postgresql/Driver.java.in b/org/postgresql/Driver.java.inindex 5f20a4e..ad5e938 100644--- a/org/postgresql/Driver.java.in+++ b/org/postgresql/Driver.java.in@@ -50,7 +50,8 @@
public static final int DEBUG = 2;
public static final int INFO = 1;
-+ public static final int OFF = 0;+
private static final Logger logger = new Logger();
private static boolean logLevelSet = false;
private static Timer cancelTimer=null;
@@ -189,8 +190,8 @@
* otherwise the jvm character encoding is used as the default.
* This value is only used when connecting to a 7.2 or older server.
* loglevel - (optional) Enable logging of messages from the driver.
- * The value is an integer from 1 to 2 where:- * INFO = 1, DEBUG = 2+ * The value is an integer from 0 to 2 where:+ * OFF = 0, INFO = 1, DEBUG = 2
* The output is sent to DriverManager.getPrintWriter() if set,
* otherwise it is sent to System.out.
* compatible - (optional) This is used to toggle
@@ -446,7 +447,7 @@
{ "sslfactoryarg", Boolean.FALSE,
"Argument forwarded to constructor of SSLSocketFactory class." },
{ "loglevel", Boolean.FALSE,
- "Control the driver's log verbosity: 0 is off, 1 is INFO, 2 is DEBUG.",+ "Control the driver's log verbosity: 0 is OFF, 1 is INFO, 2 is DEBUG.",
new String[] { "0", "1", "2" } },
{ "allowEncodingChanges", Boolean.FALSE,
"Allow the user to change the client_encoding variable." },
@@ -727,6 +728,7 @@
* used to turn logging on to a certain level, can be called
* by specifying fully qualified class ie org.postgresql.Driver.setLogLevel()
* @param logLevel sets the level which logging will respond to
+ * OFF turn off logging
* INFO being almost no messages
* DEBUG most verbose
*/=
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: chenhj@cn.fujitsu.com
Subject: Re: Patch to add a new loglevel(OFF) to turn off logging
In-Reply-To: <5122078C.90906@cn.fujitsu.com>
References: <5122078C.90906@cn.fujitsu.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox