4444import cubrid .jdbc .driver .CUBRIDDriver ;
4545import cubrid .jdbc .driver .CUBRIDXid ;
4646import cubrid .jdbc .driver .ConnectionProperties ;
47- import cubrid .jdbc .log .BasicLogger ;
48- import cubrid .jdbc .log .Log ;
4947import cubrid .jdbc .net .BrokerHandler ;
5048import cubrid .sql .CUBRIDOID ;
5149import java .io .DataOutputStream ;
5654import java .text .SimpleDateFormat ;
5755import java .util .Date ;
5856import java .util .Vector ;
57+ import java .util .logging .Level ;
58+ import java .util .logging .Logger ;
5959import javax .transaction .xa .Xid ;
6060
6161public abstract class UConnection {
@@ -215,8 +215,9 @@ public abstract class UConnection {
215215 driverInfossl [9 ] = 0 ; // reserved
216216 }
217217
218+ private static final Logger LOGGER = Logger .getLogger (UConnection .class .getName ());
219+
218220 protected UError errorHandler ;
219- protected Log log ;
220221
221222 protected ConnectionProperties connectionProperties = new ConnectionProperties ();
222223 protected CUBRIDConnection cubridcon ;
@@ -1392,19 +1393,6 @@ void cancel() throws UJciException, IOException {
13921393 /*
13931394 * logger
13941395 */
1395- protected Log getLogger () {
1396- if (log == null ) {
1397- log = new BasicLogger (connectionProperties .getLogFile ());
1398- }
1399- return log ;
1400- }
1401-
1402- protected void initLogger () {
1403- if (connectionProperties .getLogOnException () || connectionProperties .getLogSlowQueries ()) {
1404- log = getLogger ();
1405- }
1406- }
1407-
14081396 private SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss.SSS" );
14091397
14101398 public void logSlowQuery (long begin , long end , String sql , UBindParameter p ) {
@@ -1417,6 +1405,10 @@ public void logSlowQuery(long begin, long end, String sql, UBindParameter p) {
14171405 return ;
14181406 }
14191407
1408+ if (!LOGGER .isLoggable (Level .FINEST )) {
1409+ return ;
1410+ }
1411+
14201412 StringBuffer b = new StringBuffer ();
14211413 b .append ("SLOW QUERY\n " );
14221414 b .append (String .format ("[CAS INFO]\n %s:%d, %d, %d\n " , casIp , casPort , casId , casProcessId ));
@@ -1434,9 +1426,7 @@ public void logSlowQuery(long begin, long end, String sql, UBindParameter p) {
14341426 b .append ('\n' );
14351427 }
14361428
1437- synchronized (this ) {
1438- getLogger ().logInfo (b .toString ());
1439- }
1429+ LOGGER .log (Level .FINEST , b .toString ());
14401430 }
14411431
14421432 /*
@@ -1930,17 +1920,17 @@ public void setConnectionProperties(ConnectionProperties connProperties) {
19301920
19311921 public UJciException createJciException (int err ) {
19321922 UJciException e = new UJciException (err );
1933- if (connectionProperties == null || !connectionProperties .getLogOnException ()) {
1923+ if (connectionProperties == null
1924+ || !connectionProperties .getLogOnException ()
1925+ || !LOGGER .isLoggable (Level .FINE )) {
19341926 return e ;
19351927 }
19361928
19371929 StringBuffer b = new StringBuffer ();
19381930 b .append ("DUMP EXCEPTION\n " );
19391931 b .append ("[JCI EXCEPTION]" );
19401932
1941- synchronized (this ) {
1942- getLogger ().logInfo (b .toString (), e );
1943- }
1933+ LOGGER .log (Level .FINE , b .toString (), e );
19441934 return e ;
19451935 }
19461936
@@ -1951,17 +1941,18 @@ public UJciException createJciException(int err, int indicator, int srv_err, Str
19511941 }
19521942
19531943 public void logException (Throwable t ) {
1954- if (connectionProperties == null || !connectionProperties .getLogOnException ()) {
1944+ if (t == null
1945+ || connectionProperties == null
1946+ || !connectionProperties .getLogOnException ()
1947+ || !LOGGER .isLoggable (Level .FINE )) {
19551948 return ;
19561949 }
19571950
19581951 StringBuffer b = new StringBuffer ();
19591952 b .append ("DUMP EXCEPTION\n " );
19601953 b .append ("[" + t .getClass ().getName () + "]" );
19611954
1962- synchronized (this ) {
1963- getLogger ().logInfo (b .toString (), t );
1964- }
1955+ LOGGER .log (Level .FINE , b .toString (), t );
19651956 }
19661957
19671958 public boolean isActive () {
0 commit comments