Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TwsNb-0000SL-Sh for pgsql-jdbc@arkaria.postgresql.org; Sun, 20 Jan 2013 10:44:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TwsNa-0002tI-Ri for pgsql-jdbc@arkaria.postgresql.org; Sun, 20 Jan 2013 10:43:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TwsNZ-0002tC-WA for pgsql-jdbc@postgresql.org; Sun, 20 Jan 2013 10:43:58 +0000 Received: from [222.73.24.84] (helo=song.cn.fujitsu.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TwsNV-0000DD-PN for pgsql-jdbc@postgresql.org; Sun, 20 Jan 2013 10:43:57 +0000 X-IronPort-AV: E=Sophos;i="4.84,501,1355068800"; d="scan'208";a="6616129" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 20 Jan 2013 18:41:41 +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 r0KAhkdV017550; Sun, 20 Jan 2013 18:43:47 +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 2013012018425635-1043526 ; Sun, 20 Jan 2013 18:42:56 +0800 Message-ID: <50FBCA78.3040007@cn.fujitsu.com> Date: Sun, 20 Jan 2013 18:44:08 +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: dmp CC: pgsql-jdbc@postgresql.org Subject: Re: [BUGS]log can not be output when use DataSource References: <50F8335B.6070404@ttc-cmc.net> <50FA1403.7020301@cn.fujitsu.com> <50FAF98A.1030008@ttc-cmc.net> In-Reply-To: <50FAF98A.1030008@ttc-cmc.net> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/20 18:42:56, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/20 18:42:56, Serialize complete at 2013/01/20 18:42:56 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8; format=flowed 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 danap I am also a bit confused for what's the expected behavior of PgJDBC driver. I believe the following is expected.Are you agree? 1)logLevel could be set via org.postgresql.Driver.setLogLevel() 2)logLevel also could be set via connection properties(through the DriverManager or DataSource.) 3)if both (1)and (2) are set, (2)override (1) so according to (1),in the following sample ,the loglevel is expected to be DEBUG. =================================================== org.postgresql.Driver.setLogLevel(org.postgresql.Driver.DEBUG); PGPoolingDataSource source = new PGPoolingDataSource(); ...(no DataSource.setLogLevel() called) Connection con = source.getConnection(); =================================================== But the actual loglevel is 0 in existing PgJDBC driver, My patch is for that. After patched the loglevel is DEBUG. > Chen I have rebuilt the driver to include your patch which you can > use to see that the behavior I described as seems to be desired is > not achieved. I don't know what is the behavior above and is not achieved ? Chen Hujaun (2013/01/20 3:52), dmp wrote: > I now have confirmed the issue, but Chen your patch does not I believe address > the underlining behavior that should be expected from the PgJDBC driver and > that is this I believe. > > logLevel may be set via two methods. > > *************************************** > 1. org.postgresql.Driver.setLogLevel() > > 2. User defined logLevel setting via the connection properties > be it through the DriverManager or DataSource. > *************************************** > > I think most would agree and I have confirmed via the existing PgJDBC > behavior that (2), the user setting of the logLevel should override the > method (1), Driver.setLogLevel() at all times. > > The patch Chen does not seem to produce this result and perhaps that is > why it is confusing. It is true as indicated that if the user does not > user DataSource.setLogLevel() then no matter what the Driver.setLogLevel() > is set for INFO, DEBUG, it will always be the default 0 when using the > DataSource connection creation. > > Now I have wasted over an hour in determing the extent of this > reports validity and whether the patch is good. > > I suggest that patches not be accepted unless sample code is supplied > that validates/demostrates the bug and if a patch is submitted it is > tested to address the failure via the sample code. Patches should I > believe as has been addressed before almost always accompanied by > test code to validate that will added to the existing code base. > > Chen I have rebuilt the driver to include your patch which you can > use to see that the behavior I described as seems to be desired is > not achieved. > > http://dandymadeproductions.com/temp/postgresql-loglevel.jdbc4.jar > > danap. > > > Chen Huajun wrote: >> > Yes, it might be better, but I don't see how it fails otherwise ? >> >> Let me describe it again >> 1)Driver has a global LogLevel setting by the following >> org.postgresql.Driver.setLogLevel() >> >> 2)each Connection has their own LogLevel,default is the same as >> Driver's,and can be rewrited by url,for example >> jdbc:postgresql://localhost/test?loglevel=1 >> >> protected AbstractJdbc2Connection(HostSpec[] hostSpecs, String user, >> String database, Properties info, String url) throws SQLException >> { >> ... >> int logLevel = Driver.getLogLevel(); >> String connectionLogLevel = info.getProperty("loglevel"); >> if (connectionLogLevel != null) { >> try { >> logLevel = Integer.parseInt(connectionLogLevel); >> } catch (Exception l_e) { >> // XXX revisit >> // invalid value for loglevel; ignore it >> } >> } >> ... >> } >> >> 3)BaseDataSource.getConnection() will append loglevel to url regardless >> BaseDataSource.setLogLevel() was not be called >> So,the url should be as the following,and the Connection's log is off. >> jdbc:postgresql://localhost/test?loglevel=0 > > > -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc