Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SNOW-804206] 3. Instantiate JDK14Logger with sf client configuration #1384

Merged
merged 2 commits into from
May 11, 2023

Conversation

sfc-gh-skumbham
Copy link
Contributor

@sfc-gh-skumbham sfc-gh-skumbham commented May 6, 2023

Overview

SNOW-804206

The SF CONFIG file introduces various logging possibilities when used in conjunction with the tracing connection property and logging.properties for JDK14Logger. Please note that the SF CONFIG file is only applicable to JDK14Logger as SL4JLogger cannot be instantiated.

If -Djava.util.logging.config.file system property is not defined, the following actions will be taken:

Property Actions
log_level - If a value is present in the connection property, disregard value from config file
- Check log level from config file
- Default value is Level.OFF
log_path - If a non-empty LogPath is defined in the config file, set the logger output to this path
- If there are permission errors, throws a SQLException
- If no output path value is found in LogPath, defaults to java.io.tmpDir

External contributors - please answer these questions before submitting a pull request. Thanks!

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes #NNNN

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    Please write a short description of how your code change solves the related issue.

Pre-review checklist

  • This change has passed precommit
  • I have reviewed code coverage report for my PR in (Sonarqube)

@sfc-gh-skumbham sfc-gh-skumbham requested a review from a team as a code owner May 6, 2023 00:58
@sfc-gh-skumbham sfc-gh-skumbham changed the title [SNOW-804206] Instantiate JDK14Logger with sf client configuration [SNOW-804206] 3. Instantiate JDK14Logger with sf client configuration May 6, 2023
@sfc-gh-skumbham sfc-gh-skumbham force-pushed the skumbham-config-file-locator-3 branch 2 times, most recently from 2a804c1 to ae35134 Compare May 6, 2023 01:37
@sfc-gh-skumbham sfc-gh-skumbham force-pushed the skumbham-config-file-locator-3 branch from ae35134 to d5005d9 Compare May 8, 2023 03:34
@sonarqubemergegate
Copy link

SonarQube Quality Gate

Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

(String) connectionPropertiesMap.getOrDefault(SFSessionProperty.TRACING, null);

Level logLevel = null;
String logPattern = "%t/snowflake_jdbc%u.log"; // default pattern.
Copy link
Collaborator

@sfc-gh-igarish sfc-gh-igarish May 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if %t for time and %u for user then can we switch it? like %u/snowflake_jdbc_%t.log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sfc-gh-igarish We could. But we currently use %t/snowflake_jdbc%u.log this format so I kept it as-is for backward compatibility.
ref: https://github.com/snowflakedb/snowflake-jdbc/blob/master/src/main/java/net/snowflake/client/log/JDK14Logger.java#L288

Copy link
Collaborator

@sfc-gh-igarish sfc-gh-igarish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Make sure it creates unique file when run concurrently in a server environment.

@sfc-gh-skumbham
Copy link
Contributor Author

LGTM. Make sure it creates unique file when run concurrently in a server environment.

Yeah, verified. It creates one log file/process:

Screenshot 2023-05-11 at 10 45 38 AM

@sfc-gh-skumbham sfc-gh-skumbham merged commit 407aa41 into master May 11, 2023
@sfc-gh-skumbham sfc-gh-skumbham deleted the skumbham-config-file-locator-3 branch May 11, 2023 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants