Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U7OKb-00088N-LZ for pgsql-jdbc@arkaria.postgresql.org; Mon, 18 Feb 2013 10:52:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U7OKb-0004hN-2Z for pgsql-jdbc@arkaria.postgresql.org; Mon, 18 Feb 2013 10:52:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U7OKZ-0004fi-Qa for pgsql-jdbc@postgresql.org; Mon, 18 Feb 2013 10:52:19 +0000 Received: from [222.73.24.84] (helo=song.cn.fujitsu.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U7OKR-0003yB-OR for pgsql-jdbc@postgresql.org; Mon, 18 Feb 2013 10:52:18 +0000 X-IronPort-AV: E=Sophos;i="4.84,686,1355068800"; d="scan'208";a="6724179" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 18 Feb 2013 18:49:48 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r1IAq51u005074 for ; Mon, 18 Feb 2013 18:52:06 +0800 Received: from [127.0.0.1] ([10.167.159.99]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013021818512919-215228 ; Mon, 18 Feb 2013 18:51:29 +0800 Message-ID: <5122078C.90906@cn.fujitsu.com> Date: Mon, 18 Feb 2013 18:50:52 +0800 From: Chen Huajun User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.28) Gecko/20120306 Lightning/1.0b2 Thunderbird/3.1.20 MIME-Version: 1.0 To: List Subject: Patch to add a new loglevel(OFF) to turn off logging X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/02/18 18:51:29, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/02/18 18:51:29 Content-Type: multipart/mixed; boundary="------------000403000305000003080809" X-Host-Lookup-Failed: Reverse DNS lookup failed for 222.73.24.84 (failed) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org --------------000403000305000003080809 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-2022-JP 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 --------------000403000305000003080809 Content-Type: text/plain; name="pgjdbc_new_loglevel_OFF.patch" Content-Disposition: attachment; filename="pgjdbc_new_loglevel_OFF.patch" Content-Transfer-Encoding: quoted-printable diff --git a/org/postgresql/Driver.java.in b/org/postgresql/Driver.java.in index 5f20a4e..ad5e938 100644 --- a/org/postgresql/Driver.java.in +++ b/org/postgresql/Driver.java.in @@ -50,7 +50,8 @@ =20 public static final int DEBUG =3D 2; public static final int INFO =3D 1; - + public static final int OFF =3D 0; +=20=20=20=20 private static final Logger logger =3D new Logger(); private static boolean logLevelSet =3D false; private static Timer cancelTimer=3Dnull; @@ -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 =3D 1, DEBUG =3D 2 + * The value is an integer from 0 to 2 where: + * OFF =3D 0, INFO =3D 1, DEBUG =3D 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 c= lass." }, { "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.setLogL= evel() * @param logLevel sets the level which logging will respond to + * OFF turn off logging * INFO being almost no messages * DEBUG most verbose */= --------------000403000305000003080809 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc --------------000403000305000003080809--