Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TweUl-0003Hk-89 for pgsql-jdbc@arkaria.postgresql.org; Sat, 19 Jan 2013 19:54:27 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TweUj-0007UM-Sl for pgsql-jdbc@arkaria.postgresql.org; Sat, 19 Jan 2013 19:54:25 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TweUj-0007UF-02 for pgsql-jdbc@postgresql.org; Sat, 19 Jan 2013 19:54:25 +0000 Received: from outbound.vnet-inc.com ([216.146.104.103]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TweUa-0006aU-CW for pgsql-jdbc@postgresql.org; Sat, 19 Jan 2013 19:54:23 +0000 Received: from [192.168.157.132] (unknown [76.75.27.41]) by outbound.vnet-inc.com (Postfix) with ESMTP id 7CF2A592F; Sat, 19 Jan 2013 12:54:16 -0700 (MST) Message-ID: <50FAF98A.1030008@ttc-cmc.net> Date: Sat, 19 Jan 2013 12:52:42 -0700 From: dmp User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.13) Gecko/20100914 SeaMonkey/2.0.8 MIME-Version: 1.0 To: Chen Huajun , 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> In-Reply-To: <50FA1403.7020301@cn.fujitsu.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) 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 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