Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TwPbR-0003nx-Cw for pgsql-jdbc@arkaria.postgresql.org; Sat, 19 Jan 2013 04:00:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TwPbQ-0006Tu-IS for pgsql-jdbc@arkaria.postgresql.org; Sat, 19 Jan 2013 04:00:20 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TwPbP-0006Tp-TJ for pgsql-jdbc@postgresql.org; Sat, 19 Jan 2013 04:00:20 +0000 Received: from [222.73.24.84] (helo=song.cn.fujitsu.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TwPbJ-0006jB-LS for pgsql-jdbc@postgresql.org; Sat, 19 Jan 2013 04:00:18 +0000 X-IronPort-AV: E=Sophos;i="4.84,496,1355068800"; d="scan'208";a="6613881" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 19 Jan 2013 11:57:57 +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 r0J3XE8e010126; Sat, 19 Jan 2013 11:33:15 +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 2013011911321519-1036227 ; Sat, 19 Jan 2013 11:32:15 +0800 Message-ID: <50FA1403.7020301@cn.fujitsu.com> Date: Sat, 19 Jan 2013 11:33:23 +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> In-Reply-To: <50F8335B.6070404@ttc-cmc.net> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/19 11:32:15, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/19 11:32:27 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable 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 > 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,an= d can be rewrited by url,for example jdbc:postgresql://localhost/test?loglevel=3D1 protected AbstractJdbc2Connection(HostSpec[] hostSpecs, String user, S= tring database, Properties info, String url) throws SQLException { ... int logLevel =3D Driver.getLogLevel(); String connectionLogLevel =3D info.getProperty("loglevel"); if (connectionLogLevel !=3D null) { try { logLevel =3D Integer.parseInt(connectionLogLevel); } catch (Exception l_e) { // XXX revisit // invalid value for loglevel; ignore it } } ... } 3)BaseDataSource.getConnection() will append loglevel to url regardless Bas= eDataSource.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=3D0 --=20 Best Regards=EF=BC=8C Chen Huajun (2013/01/18 1:22), dmp wrote: > Also is logLevel expected in the DriverManager.getConnection(getUrl(), us= er, password)? > > According to the API jdbc:subprotocol:subname is expected and > many of the other parameters seem to not be optionally applied like login= Timeout, and socketTimeout like logLevel. > > I'm also not inclinded to understand how this is a bug and fails > to not log, though may not report the parameter properly unless > the user does setLogLevel(). > > danap. > > > Dave Cramer wrote: > > Yes, it might be better, but I don't see how it fails otherwise ? > > > > Dave Cramer > > > > dave.cramer(at)credativ(dot)ca > > http://www.credativ.ca > > > > > > On Thu, Jan 17, 2013 at 5:42 AM, Chen Huajun > > wrote: > > > > > > > It's early here but I can't see how this makes it work. It > > appears that the code that is being replaced is exactly the same > > except that there is an if statement in front of it ? > > > > > > > > > > org.postgresql.Driver.__setLogLevel(org.postgresql.__Driver.DEBUG); > > > > here the JVM level's LogLevel is set to be DEBUG. > > > > > > > > > DataSource source =3D (DataSource)new > > InitialContext().lookup("__DataSource"); > > > Connection con =3D source.getConnection(); > > > > source.getConnection() > > -->DriverManager.__getConnection(getUrl(), user, password) > > ->getUrl() > > sb.append("&loglevel=3D").__append(logLevel); > > > > here the Connection's LogLevel is set to be the initial value 0(*) > > via URL, > > although nobody set DataSource's LogLevel by calling > > BaseDataSource.setLogLevel(). > > > > I think it's better append "loglevel" to URL only when > > BaseDataSource.setLogLevel() was called. > > so a Connection created by DataSource.getConnection() can inherit > > JVM level's LogLevel setting > > just like which one created by DriverManager.getConnection(). > > > > > > *)0 is the initial value and not a valid LogLevel, > > valid values are INFO (1) and DEBUG (2). > > > > > > -- > > Best Regards, > > Chen Huajun > > (2013/01/17 17:19), Dave Cramer wrote: > > > > It's early here but I can't see how this makes it work. It > > appears that the code that is being replaced is exactly the same > > except that there is an if statement in front of it ? > > > > > > > > Dave Cramer > > > > dave.cramer(at)credativ(dot)ca > > http://www.credativ.ca > > > > > > On Wed, Jan 16, 2013 at 11:47 PM, Chen Huajun > > > > >__> > > wrote: > > > > Hi, > > > > In the following code,log can not be output as expected. > > > > ------------------------------__------- > > > > org.postgresql.Driver.__setLogLevel(org.postgresql.__Driver.DEBUG); > > DataSource source =3D (DataSource)new > > InitialContext().lookup("__DataSource"); > > Connection con =3D source.getConnection(); > > ------------------------------__------- > > > > It's seems to be a problem, > > I have made a small patch to fix it. > > Hopefully this useful. > > > > -- > > 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-jdbc > > > > --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc