From f62a9787a92b620cb883c3194bed14ccbe4273d4 Mon Sep 17 00:00:00 2001 From: Dominik Przybysz Date: Tue, 3 Dec 2024 13:44:08 +0100 Subject: [PATCH] SNOW-1652680: Limit logging on std out and info level --- .../client/config/SFClientConfigParser.java | 12 +++---- .../client/core/CredentialManager.java | 34 +++++++------------ .../client/core/FileCacheManager.java | 2 +- .../net/snowflake/client/core/FileUtil.java | 2 +- .../snowflake/client/core/IncidentUtil.java | 2 +- .../snowflake/client/core/SFBaseSession.java | 4 +-- .../net/snowflake/client/core/SFSession.java | 4 +-- .../snowflake/client/core/SFStatement.java | 8 ++--- .../core/SecureStorageAppleManager.java | 16 ++++----- .../core/SecureStorageLinuxManager.java | 4 +-- .../core/SecureStorageWindowsManager.java | 16 ++++----- .../net/snowflake/client/core/SystemUtil.java | 2 +- .../jdbc/DefaultSFConnectionHandler.java | 4 +-- .../client/jdbc/FileBackedOutputStream.java | 6 +++- .../jdbc/SnowflakeCallableStatementV1.java | 2 +- .../client/jdbc/SnowflakeChunkDownloader.java | 6 ++-- .../client/jdbc/SnowflakeConnectString.java | 4 +-- .../client/jdbc/SnowflakeConnectionV1.java | 8 ++--- .../snowflake/client/jdbc/SnowflakeUtil.java | 2 -- .../cloud/storage/SnowflakeAzureClient.java | 20 +++++------ .../cloud/storage/SnowflakeGCSClient.java | 28 +++++++-------- .../jdbc/cloud/storage/SnowflakeS3Client.java | 18 +++++----- 22 files changed, 99 insertions(+), 105 deletions(-) diff --git a/src/main/java/net/snowflake/client/config/SFClientConfigParser.java b/src/main/java/net/snowflake/client/config/SFClientConfigParser.java index 45b38dbfa..e2e50c883 100644 --- a/src/main/java/net/snowflake/client/config/SFClientConfigParser.java +++ b/src/main/java/net/snowflake/client/config/SFClientConfigParser.java @@ -37,31 +37,31 @@ public class SFClientConfigParser { */ public static SFClientConfig loadSFClientConfig(String configFilePath) throws IOException { if (configFilePath != null) { - logger.info("Attempting to enable easy logging with file path {}", configFilePath); + logger.debug("Attempting to enable easy logging with file path {}", configFilePath); } String derivedConfigFilePath = null; if (configFilePath != null && !configFilePath.isEmpty()) { // 1. Try to read the file at configFilePath. - logger.info("Using config file specified from connection string: {}", configFilePath); + logger.debug("Using config file specified from connection string: {}", configFilePath); derivedConfigFilePath = configFilePath; } else if (System.getenv().containsKey(SF_CLIENT_CONFIG_ENV_NAME)) { // 2. If SF_CLIENT_CONFIG_ENV_NAME is set, read from env. String filePath = systemGetEnv(SF_CLIENT_CONFIG_ENV_NAME); - logger.info("Using config file specified from environment variable: {}", filePath); + logger.debug("Using config file specified from environment variable: {}", filePath); derivedConfigFilePath = filePath; } else { // 3. Read SF_CLIENT_CONFIG_FILE_NAME from where jdbc jar is loaded. String driverLocation = Paths.get(getConfigFilePathFromJDBCJarLocation(), SF_CLIENT_CONFIG_FILE_NAME).toString(); if (Files.exists(Paths.get(driverLocation))) { - logger.info("Using config file specified from driver directory: {}", driverLocation); + logger.debug("Using config file specified from driver directory: {}", driverLocation); derivedConfigFilePath = driverLocation; } else { // 4. Read SF_CLIENT_CONFIG_FILE_NAME if it is present in user home directory. String userHomeFilePath = Paths.get(systemGetProperty("user.home"), SF_CLIENT_CONFIG_FILE_NAME).toString(); if (Files.exists(Paths.get(userHomeFilePath))) { - logger.info("Using config file specified from home directory: {}", userHomeFilePath); + logger.debug("Using config file specified from home directory: {}", userHomeFilePath); derivedConfigFilePath = userHomeFilePath; } } @@ -73,7 +73,7 @@ public static SFClientConfig loadSFClientConfig(String configFilePath) throws IO File configFile = new File(derivedConfigFilePath); ObjectMapper objectMapper = new ObjectMapper(); SFClientConfig clientConfig = objectMapper.readValue(configFile, SFClientConfig.class); - logger.info( + logger.debug( "Reading values logLevel {} and logPath {} from client configuration", clientConfig.getCommonProps().getLogLevel(), clientConfig.getCommonProps().getLogPath()); diff --git a/src/main/java/net/snowflake/client/core/CredentialManager.java b/src/main/java/net/snowflake/client/core/CredentialManager.java index 08e9e6b9a..691430edd 100644 --- a/src/main/java/net/snowflake/client/core/CredentialManager.java +++ b/src/main/java/net/snowflake/client/core/CredentialManager.java @@ -32,9 +32,7 @@ private void initSecureStorageManager() { logger.error("Unsupported Operating System. Expected: OSX, Windows, Linux", false); } } catch (NoClassDefFoundError error) { - logger.info( - "JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.", - false); + logMissingJnaJarForSecureLocalStorage(); } } @@ -97,9 +95,7 @@ void fillCachedMfaToken(SFLoginInput loginInput) throws SFException { synchronized void fillCachedCredential(SFLoginInput loginInput, String credType) throws SFException { if (secureStorageManager == null) { - logger.info( - "JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.", - false); + logMissingJnaJarForSecureLocalStorage(); return; } @@ -109,9 +105,7 @@ synchronized void fillCachedCredential(SFLoginInput loginInput, String credType) secureStorageManager.getCredential( loginInput.getHostFromServerUrl(), loginInput.getUserName(), credType); } catch (NoClassDefFoundError error) { - logger.info( - "JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.", - false); + logMissingJnaJarForSecureLocalStorage(); return; } @@ -183,9 +177,7 @@ synchronized void writeTemporaryCredential(SFLoginInput loginInput, String cred, } if (secureStorageManager == null) { - logger.info( - "JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.", - false); + logMissingJnaJarForSecureLocalStorage(); return; } @@ -193,9 +185,7 @@ synchronized void writeTemporaryCredential(SFLoginInput loginInput, String cred, secureStorageManager.setCredential( loginInput.getHostFromServerUrl(), loginInput.getUserName(), credType, cred); } catch (NoClassDefFoundError error) { - logger.info( - "JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.", - false); + logMissingJnaJarForSecureLocalStorage(); } } @@ -222,18 +212,20 @@ void deleteMfaTokenCache(String host, String user) { */ synchronized void deleteTemporaryCredential(String host, String user, String credType) { if (secureStorageManager == null) { - logger.info( - "JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.", - false); + logMissingJnaJarForSecureLocalStorage(); return; } try { secureStorageManager.deleteCredential(host, user, credType); } catch (NoClassDefFoundError error) { - logger.info( - "JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.", - false); + logMissingJnaJarForSecureLocalStorage(); } } + + private static void logMissingJnaJarForSecureLocalStorage() { + logger.warn( + "JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall back to normal process.", + false); + } } diff --git a/src/main/java/net/snowflake/client/core/FileCacheManager.java b/src/main/java/net/snowflake/client/core/FileCacheManager.java index 328aecc9c..05972b620 100644 --- a/src/main/java/net/snowflake/client/core/FileCacheManager.java +++ b/src/main/java/net/snowflake/client/core/FileCacheManager.java @@ -165,7 +165,7 @@ FileCacheManager build() { this.cacheLockFile = new File(this.cacheFile.getParentFile(), this.baseCacheFileName + ".lck"); } catch (IOException | SecurityException ex) { - logger.info("Failed to touch the cache file. Ignored. {}", cacheFileTmp.getAbsoluteFile()); + logger.debug("Failed to touch the cache file. Ignored. {}", cacheFileTmp.getAbsoluteFile()); } return this; } diff --git a/src/main/java/net/snowflake/client/core/FileUtil.java b/src/main/java/net/snowflake/client/core/FileUtil.java index 3ae68909b..0e12ec4aa 100644 --- a/src/main/java/net/snowflake/client/core/FileUtil.java +++ b/src/main/java/net/snowflake/client/core/FileUtil.java @@ -21,7 +21,7 @@ public class FileUtil { Arrays.asList(PosixFilePermission.GROUP_READ, PosixFilePermission.OTHERS_READ); public static void logFileUsage(Path filePath, String context, boolean logReadAccess) { - logger.info("{}Accessing file: {}", getContextStr(context), filePath); + logger.debug("{}Accessing file: {}", getContextStr(context), filePath); logWarnWhenAccessibleByOthers(filePath, context, logReadAccess); } diff --git a/src/main/java/net/snowflake/client/core/IncidentUtil.java b/src/main/java/net/snowflake/client/core/IncidentUtil.java index 0506f159b..41d31c5cd 100644 --- a/src/main/java/net/snowflake/client/core/IncidentUtil.java +++ b/src/main/java/net/snowflake/client/core/IncidentUtil.java @@ -206,7 +206,7 @@ private static void writeVmMetrics(JsonGenerator json, VirtualMachineMetrics vm) // This function can throw an error with java 11. json.writeNumberField("fd_usage", vm.fileDescriptorUsage()); } catch (Exception e) { - logger.info("Error writing fd_usage", e); + logger.debug("Error writing fd_usage", e); } json.writeFieldName("thread-states"); diff --git a/src/main/java/net/snowflake/client/core/SFBaseSession.java b/src/main/java/net/snowflake/client/core/SFBaseSession.java index 9222b4a57..9d1a09be1 100644 --- a/src/main/java/net/snowflake/client/core/SFBaseSession.java +++ b/src/main/java/net/snowflake/client/core/SFBaseSession.java @@ -675,7 +675,7 @@ public HttpClientSettingsKey getHttpClientKey() throws SnowflakeSQLException { private void logHttpClientInitInfo(HttpClientSettingsKey key) { if (key.usesProxy()) { - logger.info( + logger.debug( "Driver OCSP mode: {}, gzip disabled: {}, proxy protocol: {}," + " proxy host: {}, proxy port: {}, non proxy hosts: {}, proxy user: {}, proxy password is {}", key.getOcspMode(), @@ -687,7 +687,7 @@ private void logHttpClientInitInfo(HttpClientSettingsKey key) { key.getProxyUser(), key.getProxyPassword().isEmpty() ? "not set" : "set"); } else { - logger.info( + logger.debug( "Driver OCSP mode: {}, gzip disabled: {} and no proxy", key.getOcspMode(), key.getGzipDisabled()); diff --git a/src/main/java/net/snowflake/client/core/SFSession.java b/src/main/java/net/snowflake/client/core/SFSession.java index d26da7828..5e583de30 100644 --- a/src/main/java/net/snowflake/client/core/SFSession.java +++ b/src/main/java/net/snowflake/client/core/SFSession.java @@ -794,7 +794,7 @@ public synchronized void open() throws SFException, SnowflakeSQLException { // start heartbeat for this session so that the master token will not expire startHeartbeatForThisSession(); stopwatch.stop(); - logger.info("Session {} opened in {} ms.", getSessionId(), stopwatch.elapsedMillis()); + logger.debug("Session {} opened in {} ms.", getSessionId(), stopwatch.elapsedMillis()); } /** @@ -937,7 +937,7 @@ public void close() throws SFException, SnowflakeSQLException { } stopwatch.stop(); - logger.info( + logger.debug( "Session {} has been successfully closed in {} ms", getSessionId(), stopwatch.elapsedMillis()); diff --git a/src/main/java/net/snowflake/client/core/SFStatement.java b/src/main/java/net/snowflake/client/core/SFStatement.java index 173ecf21f..0d0668e27 100644 --- a/src/main/java/net/snowflake/client/core/SFStatement.java +++ b/src/main/java/net/snowflake/client/core/SFStatement.java @@ -435,11 +435,11 @@ public Object executeHelper( } if (numBinds > 0 && session.getPreparedStatementLogging()) { if (numBinds > MAX_BINDING_PARAMS_FOR_LOGGING) { - logger.info( + logger.debug( "Number of binds exceeds logging limit. Printing off {} binding parameters.", MAX_BINDING_PARAMS_FOR_LOGGING); } else { - logger.info("Printing off {} binding parameters.", numBinds); + logger.debug("Printing off {} binding parameters.", numBinds); } int counter = 0; // if it's an array bind, print off the first few rows from each column. @@ -458,7 +458,7 @@ public Object executeHelper( rows += bindRows.get(i) + ", "; } rows += "]"; - logger.info("Column {}: {}", entry.getKey(), rows); + logger.debug("Column {}: {}", entry.getKey(), rows); counter += numRowsPrinted; if (counter >= MAX_BINDING_PARAMS_FOR_LOGGING) { break; @@ -472,7 +472,7 @@ public Object executeHelper( break; } counter++; - logger.info("Column {}: {}", entry.getKey(), entry.getValue().getValue()); + logger.debug("Column {}: {}", entry.getKey(), entry.getValue().getValue()); } } } diff --git a/src/main/java/net/snowflake/client/core/SecureStorageAppleManager.java b/src/main/java/net/snowflake/client/core/SecureStorageAppleManager.java index 5030e4603..1bb8cebaf 100644 --- a/src/main/java/net/snowflake/client/core/SecureStorageAppleManager.java +++ b/src/main/java/net/snowflake/client/core/SecureStorageAppleManager.java @@ -22,13 +22,13 @@ private SecureStorageAppleManager() { } public static SecureStorageAppleManager builder() { - logger.info("Using Apple Keychain as a token cache storage"); + logger.debug("Using Apple Keychain as a token cache storage"); return new SecureStorageAppleManager(); } public SecureStorageStatus setCredential(String host, String user, String type, String cred) { if (Strings.isNullOrEmpty(cred)) { - logger.info("No credential provided", false); + logger.debug("No credential provided", false); return SecureStorageStatus.SUCCESS; } @@ -53,7 +53,7 @@ public SecureStorageStatus setCredential(String host, String user, String type, } if (errCode != SecurityLib.ERR_SEC_SUCCESS && errCode != SecurityLib.ERR_SEC_ITEM_NOT_FOUND) { - logger.info( + logger.warn( String.format( "Failed to check the existence of the item in keychain. Error code = %d", Native.getLastError())); @@ -81,7 +81,7 @@ public SecureStorageStatus setCredential(String host, String user, String type, } if (errCode != SecurityLib.ERR_SEC_SUCCESS) { - logger.info( + logger.warn( String.format( "Failed to set/modify the item in keychain. Error code = %d", Native.getLastError())); return SecureStorageStatus.FAILURE; @@ -115,14 +115,14 @@ public String getCredential(String host, String user, String type) { } if (errCode != SecurityLib.ERR_SEC_SUCCESS) { - logger.info( + logger.warn( String.format( "Failed to find the item in keychain or item not exists. Error code = %d", Native.getLastError())); return null; } if (dataLength[0] == 0 || data[0] == null) { - logger.info("Found empty item or no item is found", false); + logger.debug("Found empty item or no item is found", false); return null; } @@ -162,7 +162,7 @@ public SecureStorageStatus deleteCredential(String host, String user, String typ } if (errCode != SecurityLib.ERR_SEC_SUCCESS && errCode != SecurityLib.ERR_SEC_ITEM_NOT_FOUND) { - logger.info( + logger.warn( String.format( "Failed to delete the item in keychain. Error code = %d", Native.getLastError())); return SecureStorageStatus.FAILURE; @@ -174,7 +174,7 @@ public SecureStorageStatus deleteCredential(String host, String user, String typ } if (errCode != SecurityLib.ERR_SEC_SUCCESS) { - logger.info( + logger.warn( String.format( "Failed to delete the item in keychain. Error code = %d", Native.getLastError())); return SecureStorageStatus.FAILURE; diff --git a/src/main/java/net/snowflake/client/core/SecureStorageLinuxManager.java b/src/main/java/net/snowflake/client/core/SecureStorageLinuxManager.java index 7663147b3..f395147d9 100644 --- a/src/main/java/net/snowflake/client/core/SecureStorageLinuxManager.java +++ b/src/main/java/net/snowflake/client/core/SecureStorageLinuxManager.java @@ -41,7 +41,7 @@ private SecureStorageLinuxManager() { .setCacheExpirationInSeconds(CACHE_EXPIRATION_IN_SECONDS) .setCacheFileLockExpirationInSeconds(CACHE_FILE_LOCK_EXPIRATION_IN_SECONDS) .build(); - logger.info( + logger.debug( "Using temporary file: {} as a token cache storage", fileCacheManager.getCacheFilePath()); } @@ -70,7 +70,7 @@ private ObjectNode localCacheToJson() { public synchronized SecureStorageStatus setCredential( String host, String user, String type, String token) { if (Strings.isNullOrEmpty(token)) { - logger.info("No token provided", false); + logger.debug("No token provided", false); return SecureStorageStatus.SUCCESS; } diff --git a/src/main/java/net/snowflake/client/core/SecureStorageWindowsManager.java b/src/main/java/net/snowflake/client/core/SecureStorageWindowsManager.java index f38c1570b..1a01251d9 100644 --- a/src/main/java/net/snowflake/client/core/SecureStorageWindowsManager.java +++ b/src/main/java/net/snowflake/client/core/SecureStorageWindowsManager.java @@ -33,13 +33,13 @@ private SecureStorageWindowsManager() { } public static SecureStorageWindowsManager builder() { - logger.info("Using Windows Credential Manager as a token cache storage"); + logger.debug("Using Windows Credential Manager as a token cache storage"); return new SecureStorageWindowsManager(); } public SecureStorageStatus setCredential(String host, String user, String type, String token) { if (Strings.isNullOrEmpty(token)) { - logger.info("No token provided", false); + logger.debug("No token provided", false); return SecureStorageStatus.SUCCESS; } @@ -63,13 +63,13 @@ public SecureStorageStatus setCredential(String host, String user, String type, } if (!ret) { - logger.info( + logger.warn( String.format( "Failed to write to Windows Credential Manager. Error code = %d", Native.getLastError())); return SecureStorageStatus.FAILURE; } - logger.info("Wrote to Windows Credential Manager successfully", false); + logger.debug("Wrote to Windows Credential Manager successfully", false); return SecureStorageStatus.SUCCESS; } @@ -90,7 +90,7 @@ public String getCredential(String host, String user, String type) { } if (!ret) { - logger.info( + logger.warn( String.format( "Failed to read target or could not find it in Windows Credential Manager. Error code = %d", Native.getLastError())); @@ -104,12 +104,12 @@ public String getCredential(String host, String user, String type) { if (SecureStorageWindowsCredentialType.typeOf(cred.Type) != SecureStorageWindowsCredentialType.CRED_TYPE_GENERIC) { - logger.info("Wrong type of credential. Expected: CRED_TYPE_GENERIC", false); + logger.warn("Wrong type of credential. Expected: CRED_TYPE_GENERIC", false); return null; } if (cred.CredentialBlobSize == 0) { - logger.info("Returned credential is empty", false); + logger.debug("Returned credential is empty", false); return null; } @@ -137,7 +137,7 @@ public SecureStorageStatus deleteCredential(String host, String user, String typ } if (!ret) { - logger.info( + logger.warn( String.format( "Failed to delete target in Windows Credential Manager. Error code = %d", Native.getLastError())); diff --git a/src/main/java/net/snowflake/client/core/SystemUtil.java b/src/main/java/net/snowflake/client/core/SystemUtil.java index 1094261eb..721d83151 100644 --- a/src/main/java/net/snowflake/client/core/SystemUtil.java +++ b/src/main/java/net/snowflake/client/core/SystemUtil.java @@ -26,7 +26,7 @@ static int convertSystemPropertyToIntValue(String systemProperty, int defaultVal try { returnVal = Integer.parseInt(systemPropertyValue); } catch (NumberFormatException ex) { - logger.info( + logger.warn( "Failed to parse the system parameter {} with value {}", systemProperty, systemPropertyValue); diff --git a/src/main/java/net/snowflake/client/jdbc/DefaultSFConnectionHandler.java b/src/main/java/net/snowflake/client/jdbc/DefaultSFConnectionHandler.java index 67151bea8..ee9d5f307 100644 --- a/src/main/java/net/snowflake/client/jdbc/DefaultSFConnectionHandler.java +++ b/src/main/java/net/snowflake/client/jdbc/DefaultSFConnectionHandler.java @@ -189,7 +189,7 @@ && systemGetProperty("java.util.logging.config.file") == null) { if (logLevel != null && logPattern != null) { try { - logger.info("Setting logger with log level {} and log pattern {}", logLevel, logPattern); + logger.debug("Setting logger with log level {} and log pattern {}", logLevel, logPattern); JDK14Logger.instantiateLogger(logLevel, logPattern); } catch (IOException ex) { throw new SnowflakeSQLLoggedException( @@ -325,7 +325,7 @@ private void initSessionProperties(SnowflakeConnectString conStr, String appID, properties.replace(property.getKey(), "900"); } } catch (NumberFormatException ex) { - logger.info( + logger.warn( "Invalid data type for CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY: {}", property.getValue()); continue; diff --git a/src/main/java/net/snowflake/client/jdbc/FileBackedOutputStream.java b/src/main/java/net/snowflake/client/jdbc/FileBackedOutputStream.java index 14fb7dbdc..d1de7bfb9 100644 --- a/src/main/java/net/snowflake/client/jdbc/FileBackedOutputStream.java +++ b/src/main/java/net/snowflake/client/jdbc/FileBackedOutputStream.java @@ -27,6 +27,8 @@ import java.io.InputStream; import java.io.OutputStream; import net.snowflake.client.core.FileUtil; +import net.snowflake.client.log.SFLogger; +import net.snowflake.client.log.SFLoggerFactory; /** * An {@link OutputStream} that starts buffering to a byte array, but switches to file buffering @@ -42,6 +44,8 @@ @Beta public final class FileBackedOutputStream extends OutputStream { + private static final SFLogger logger = SFLoggerFactory.getLogger(FileBackedOutputStream.class); + private final int fileThreshold; private final boolean resetOnFinalize; private final ByteSource source; @@ -105,7 +109,7 @@ protected void finalize() { try { reset(); } catch (Throwable t) { - t.printStackTrace(System.err); + logger.error("Exception occurred on finalize", t); } } }; diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeCallableStatementV1.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeCallableStatementV1.java index 930e70039..7bc3f87d5 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeCallableStatementV1.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeCallableStatementV1.java @@ -65,7 +65,7 @@ final class SnowflakeCallableStatementV1 extends SnowflakePreparedStatementV1 static String parseSqlEscapeSyntax(String originalSql) { originalSql = originalSql.trim(); if (originalSql.startsWith("{") && originalSql.endsWith("}")) { - logger.info("Curly brackets {} removed before sending sql to server.", false); + logger.debug("Curly brackets {} removed before sending sql to server.", false); return originalSql.substring(1, originalSql.length() - 1); } return originalSql; diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeChunkDownloader.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeChunkDownloader.java index fe1880083..674606f3a 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeChunkDownloader.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeChunkDownloader.java @@ -842,7 +842,7 @@ public DownloaderMetrics terminate() throws InterruptedException { chunks.stream().reduce(0L, (acc, chunk) -> acc + chunk.getRowCount(), Long::sum); long chunksSize = chunks.size(); - logger.info( + logger.debug( "Completed processing {} {} chunks for query {} in {} ms. Download took {} ms (average: {} ms)," + " parsing took {} ms (average: {} ms). Chunks uncompressed size: {} MB (average: {} MB)," + " rows in chunks: {} (total: {}, average in chunk: {}), total memory used: {} MB", @@ -1034,7 +1034,7 @@ public Void call() { "Thread {} finish downloading chunk#{}", Thread.currentThread().getId(), chunkIndex); downloader.downloaderFutures.remove(chunkIndex); if (chunkIndex % 5 == 0) { - logger.info( + logger.debug( "Processed {} chunk#{} in {} ms ({} out of {}) for query {}. Download took {} ms, " + "parsing took {} ms. Chunk uncompressed size: {} kB, cols: {}, rows: {}, scrubbed URL: {}", downloader.queryResultFormat == QueryResultFormat.ARROW ? "ARROW" : "JSON", @@ -1050,7 +1050,7 @@ public Void call() { resultChunk.rowCount, resultChunk.getScrubbedUrl()); } else { - logger.debug( + logger.trace( "Processed {} chunk#{} in {} ms ({} out of {}) for query {}. Download took {} ms, " + "parsing took {} ms. Chunk uncompressed size: {} kB, cols: {}, rows: {}, scrubbed URL: {}", downloader.queryResultFormat == QueryResultFormat.ARROW ? "ARROW" : "JSON", diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeConnectString.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeConnectString.java index e918edf50..440ed14f7 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeConnectString.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeConnectString.java @@ -106,7 +106,7 @@ public static SnowflakeConnectString parse(String url, Properties info) { } parameters.put(k.toUpperCase(Locale.US), v); } catch (UnsupportedEncodingException ex0) { - logger.info("Failed to decode a parameter {}. Ignored.", p); + logger.warn("Failed to decode a parameter {}. Ignored.", p); } } } @@ -216,7 +216,7 @@ public String toString(boolean maskSensitiveValue) { urlStr.append(v); } } catch (UnsupportedEncodingException ex) { - logger.info("Failed to encode a parameter {}. Ignored.", entry.getKey()); + logger.warn("Failed to encode a parameter {}. Ignored.", entry.getKey()); } ++cnt; } diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeConnectionV1.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeConnectionV1.java index 1f55c83f4..23ce7d2ef 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeConnectionV1.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeConnectionV1.java @@ -145,14 +145,14 @@ private void initConnectionWithImpl( SFConnectionHandler sfConnectionHandler, String url, Properties info) throws SQLException { Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); - logger.info("Initializing new connection"); + logger.debug("Initializing new connection"); this.sfConnectionHandler = sfConnectionHandler; sfConnectionHandler.initializeConnection(url, info); this.sfSession = sfConnectionHandler.getSFSession(); missingProperties = sfSession.checkProperties(); this.showStatementParameters = sfSession.getPreparedStatementLogging(); stopwatch.stop(); - logger.info( + logger.debug( "Connection initialized successfully in {} ms. Session id: {}", stopwatch.elapsedMillis(), sfSession.getSessionId()); @@ -240,7 +240,7 @@ public void close() throws SQLException { if (sfSession != null) { sessionId = sfSession.getSessionId(); - logger.info("Closing connection with session id: {}", sessionId); + logger.debug("Closing connection with session id: {}", sessionId); } else { logger.debug("Closing connection without associated session"); } @@ -280,7 +280,7 @@ public void close() throws SQLException { sfSession, ex.getSqlState(), ex.getVendorCode(), ex.getCause(), ex.getParams()); } stopwatch.stop(); - logger.info( + logger.debug( "Connection with session id: {} closed successfully in {} ms", sessionId, stopwatch.elapsedMillis()); diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeUtil.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeUtil.java index 8e9a683a0..fbfa84676 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeUtil.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeUtil.java @@ -700,7 +700,6 @@ public static void systemSetEnv(String key, String value) { writableEnvForGet.put(key, value); } } catch (Exception e) { - System.out.println("Failed to set value"); logger.error( "Failed to set environment variable {}. Exception raised: {}", key, e.getMessage()); } @@ -720,7 +719,6 @@ public static void systemUnsetEnv(String key) { Map writableEnv = (Map) field.get(env); writableEnv.remove(key); } catch (Exception e) { - System.out.println("Failed to unset value"); logger.error( "Failed to remove environment variable {}. Exception raised: {}", key, e.getMessage()); } diff --git a/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeAzureClient.java b/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeAzureClient.java index 0f8014ef6..401dea8ec 100644 --- a/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeAzureClient.java +++ b/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeAzureClient.java @@ -94,7 +94,7 @@ private SnowflakeAzureClient() {} public static SnowflakeAzureClient createSnowflakeAzureClient( StageInfo stage, RemoteStoreFileEncryptionMaterial encMat, SFBaseSession sfSession) throws SnowflakeSQLException { - logger.info( + logger.debug( "Initializing Snowflake Azure client with encryption: {}", encMat != null ? "true" : "false"); SnowflakeAzureClient azureClient = new SnowflakeAzureClient(); @@ -330,7 +330,7 @@ public void download( Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); String localFilePath = localLocation + localFileSep + destFileName; - logger.info( + logger.debug( "Staring download of file from Azure stage path: {} to {}", stageFilePath, localFilePath); int retryCount = 0; do { @@ -374,7 +374,7 @@ public void download( EncryptionProvider.decrypt(localFile, key, iv, this.encMat); stopwatch.stop(); long decryptMillis = stopwatch.elapsedMillis(); - logger.info( + logger.debug( "Azure file {} downloaded to {}. It took {} ms (download: {} ms, decryption: {} ms) with {} retries", remoteStorageLocation, localFile.getAbsolutePath(), @@ -387,7 +387,7 @@ public void download( throw ex; } } else { - logger.info( + logger.debug( "Azure file {} downloaded to {}. It took {} ms with {} retries", remoteStorageLocation, localFile.getAbsolutePath(), @@ -435,7 +435,7 @@ public InputStream downloadToStream( String presignedUrl, String queryId) throws SnowflakeSQLException { - logger.info( + logger.debug( "Staring download of file from Azure stage path: {} to input stream", stageFilePath); Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); @@ -472,7 +472,7 @@ public InputStream downloadToStream( InputStream is = EncryptionProvider.decryptStream(stream, key, iv, encMat); stopwatch.stop(); long decryptMillis = stopwatch.elapsedMillis(); - logger.info( + logger.debug( "Azure file {} downloaded to input stream. It took {} ms " + "(download: {} ms, decryption: {} ms) with {} retries", stageFilePath, @@ -488,7 +488,7 @@ public InputStream downloadToStream( } } else { - logger.info( + logger.debug( "Azure file {} downloaded to input stream. Download took {} ms with {} retries", stageFilePath, downloadMillis, @@ -544,7 +544,7 @@ public void upload( String presignedUrl, String queryId) throws SnowflakeSQLException { - logger.info( + logger.debug( StorageHelper.getStartUploadLog( "Azure", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName)); final List toClose = new ArrayList<>(); @@ -589,13 +589,13 @@ public void upload( stopwatch.stop(); if (uploadFromStream) { - logger.info( + logger.debug( "Uploaded data from input stream to Azure location: {}. It took {} ms with {} retries", remoteStorageLocation, stopwatch.elapsedMillis(), retryCount); } else { - logger.info( + logger.debug( "Uploaded file {} to Azure location: {}. It took {} ms with {} retries", srcFile.getAbsolutePath(), remoteStorageLocation, diff --git a/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeGCSClient.java b/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeGCSClient.java index d6bf6ba84..40e359549 100644 --- a/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeGCSClient.java +++ b/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeGCSClient.java @@ -259,7 +259,7 @@ public void download( String queryId) throws SnowflakeSQLException { String localFilePath = localLocation + localFileSep + destFileName; - logger.info( + logger.debug( "Staring download of file from GCS stage path: {} to {}", stageFilePath, localFilePath); int retryCount = 0; Stopwatch stopwatch = new Stopwatch(); @@ -388,7 +388,7 @@ public void download( EncryptionProvider.decrypt(localFile, key, iv, this.encMat); stopwatch.stop(); long decryptMillis = stopwatch.elapsedMillis(); - logger.info( + logger.debug( "GCS file {} downloaded to {}. It took {} ms (download: {} ms, decryption: {} ms) with {} retries", stageFilePath, localFile.getAbsolutePath(), @@ -406,7 +406,7 @@ public void download( "Cannot decrypt file"); } } else { - logger.info( + logger.debug( "GCS file {} downloaded to {}. It took {} ms with {} retries", stageFilePath, localFile.getAbsolutePath(), @@ -453,7 +453,7 @@ public InputStream downloadToStream( String presignedUrl, String queryId) throws SnowflakeSQLException { - logger.info("Staring download of file from GCS stage path: {} to input stream", stageFilePath); + logger.debug("Staring download of file from GCS stage path: {} to input stream", stageFilePath); int retryCount = 0; Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); @@ -565,7 +565,7 @@ public InputStream downloadToStream( inputStream = EncryptionProvider.decryptStream(inputStream, key, iv, this.encMat); stopwatch.stop(); long decryptMillis = stopwatch.elapsedMillis(); - logger.info( + logger.debug( "GCS file {} downloaded to stream. It took {} ms (download: {} ms, decryption: {} ms) with {} retries", stageFilePath, downloadMillis + decryptMillis, @@ -584,7 +584,7 @@ public InputStream downloadToStream( "Cannot decrypt file"); } } else { - logger.info( + logger.debug( "GCS file {} downloaded to stream. Download took {} ms with {} retries", stageFilePath, downloadMillis, @@ -640,7 +640,7 @@ public void uploadWithPresignedUrlWithoutConnection( String presignedUrl, String queryId) throws SnowflakeSQLException { - logger.info( + logger.debug( StorageHelper.getStartUploadLog( "GCS", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName)); final List toClose = new ArrayList<>(); @@ -690,12 +690,12 @@ public void uploadWithPresignedUrlWithoutConnection( stopwatch.stop(); if (uploadFromStream) { - logger.info( + logger.debug( "Uploaded data from input stream to GCS location: {}. It took {} ms", remoteStorageLocation, stopwatch.elapsedMillis()); } else { - logger.info( + logger.debug( "Uploaded file {} to GCS location: {}. It took {} ms", srcFile.getAbsolutePath(), remoteStorageLocation, @@ -742,7 +742,7 @@ public void upload( String presignedUrl, String queryId) throws SnowflakeSQLException { - logger.info( + logger.debug( StorageHelper.getStartUploadLog( "GCS", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName)); final List toClose = new ArrayList<>(); @@ -780,12 +780,12 @@ public void upload( stopwatch.stop(); logger.debug("Upload successful", false); if (uploadFromStream) { - logger.info( + logger.debug( "Uploaded data from input stream to GCS location: {}. It took {} ms", remoteStorageLocation, stopwatch.elapsedMillis()); } else { - logger.info( + logger.debug( "Uploaded file {} to GCS location: {}. It took {} ms", srcFile.getAbsolutePath(), remoteStorageLocation, @@ -817,12 +817,12 @@ public void upload( stopwatch.stop(); logger.debug("Upload successful", false); if (uploadFromStream) { - logger.info( + logger.debug( "Uploaded data from input stream to GCS location: {}. It took {} ms", remoteStorageLocation, stopwatch.elapsedMillis()); } else { - logger.info( + logger.debug( "Uploaded file {} to GCS location: {}. It took {} ms", srcFile.getAbsolutePath(), remoteStorageLocation, diff --git a/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeS3Client.java b/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeS3Client.java index f1a2392bb..e6bc9a11c 100644 --- a/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeS3Client.java +++ b/src/main/java/net/snowflake/client/jdbc/cloud/storage/SnowflakeS3Client.java @@ -352,7 +352,7 @@ public void download( Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); String localFilePath = localLocation + localFileSep + destFileName; - logger.info( + logger.debug( "Staring download of file from S3 stage path: {} to {}", stageFilePath, localFilePath); TransferManager tx = null; int retryCount = 0; @@ -407,7 +407,7 @@ public ExecutorService newExecutor() { EncryptionProvider.decrypt(localFile, key, iv, this.encMat); stopwatch.stop(); long decryptMillis = stopwatch.elapsedMillis(); - logger.info( + logger.debug( "S3 file {} downloaded to {}. It took {} ms (download: {} ms, decryption: {} ms) with {} retries", stageFilePath, localFile.getAbsolutePath(), @@ -420,7 +420,7 @@ public ExecutorService newExecutor() { throw ex; } } else { - logger.info( + logger.debug( "S3 file {} downloaded to {}. It took {} ms with {} retries", stageFilePath, localFile.getAbsolutePath(), @@ -473,7 +473,7 @@ public InputStream downloadToStream( String presignedUrl, String queryId) throws SnowflakeSQLException { - logger.info("Staring download of file from S3 stage path: {} to input stream", stageFilePath); + logger.debug("Staring download of file from S3 stage path: {} to input stream", stageFilePath); Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); int retryCount = 0; @@ -505,7 +505,7 @@ public InputStream downloadToStream( InputStream is = EncryptionProvider.decryptStream(stream, key, iv, encMat); stopwatch.stop(); long decryptMillis = stopwatch.elapsedMillis(); - logger.info( + logger.debug( "S3 file {} downloaded to input stream. It took {} ms " + "(download: {} ms, decryption: {} ms) with {} retries", stageFilePath, @@ -520,7 +520,7 @@ public InputStream downloadToStream( throw ex; } } else { - logger.info( + logger.debug( "S3 file {} downloaded to input stream. Download took {} ms with {} retries", stageFilePath, downloadMillis, @@ -574,7 +574,7 @@ public void upload( String presignedUrl, String queryId) throws SnowflakeSQLException { - logger.info( + logger.debug( StorageHelper.getStartUploadLog( "S3", uploadFromStream, inputStream, fileBackedOutputStream, srcFile, destFileName)); @@ -649,13 +649,13 @@ public ExecutorService newExecutor() { } if (uploadFromStream) { - logger.info( + logger.debug( "Uploaded data from input stream to S3 location: {}. It took {} ms with {} retries", destFileName, uploadMillis, retryCount); } else { - logger.info( + logger.debug( "Uploaded file {} to S3 location: {}. It took {} ms with {} retries", srcFile.getAbsolutePath(), destFileName,