Skip to content

Commit

Permalink
AT-1469 modify imports and add additional information for tracing the…
Browse files Browse the repository at this point in the history
… logs information
  • Loading branch information
dkovalenkoI committed Jul 26, 2023
1 parent d803df7 commit d9ce589
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,20 +456,69 @@ Javadoc JAR builds with `mvn install` alongside the other JAR files. To extract

### Debug with BI tools
#### DBeaver
To enable debug logs, the application should be run with `-Ddbeaver.trace.enabled=true` flag
1. Search `dbeaver.ini` file - It should be in the home DBeaver directory
2. Open `dbeaver.ini` file and add line `-Ddbeaver.jdbc.trace=true` to the end of the file
3. Restart DBeaver Application
4. Add driver and Connect to your timestream database.
5. In DBeaver `Workspace` go to `.metadata` folder
6. File `jdbc-api-trace.log` contains all JDBC API invocations and all queries with results.

##### The log location Mac example
/Library/DBeaverData/workspace6/.metadata/dbeaver-debug.log

#### Log example
2023-07-24 14:53:57.819 - Initializing the client.
2023-07-24 14:53:57.819 - Creating an AWSStaticCredentialsProvider.
2023-07-24 14:53:58.375 - Execution context opened (Timestream; Metadata; 1)
2023-07-24 14:53:58.377 - Initializing the client.
2023-07-24 14:53:58.377 - Creating an AWSStaticCredentialsProvider.

#### DbVisualizer
To enable debug mode, the following steps should be done:
1. Open `Tools -> Debug Window`
2. Open the `Debug Log` tab
3. Enable the `Debug DbVisualizer` checkbox

##### The log file location
`$HOME/.dbvis/sqllogs folder with the .dson extension`

#### Tableau Desktop
To enable debug mode need to run Tableau Desktop with -DLogLevel=debug flag
More details on the official [documentation](https://kb.tableau.com/articles/howto/how-to-create-tableau-desktop-debug-logs)

#### Java Application
Need to change log level to Debug/FINE. See official documentation how to change log level.
Need to change the log level to `DEBUG` or `FINE`.

#### For Spring based application
The log level can be modified by changing application.properties

`logging.level.root=DEBUG`
`logging.level.software.amazon.timestream.jdbc=FINE`

#### By VM arguments
1. Create file `logging.properties`
2. Add line `software.amazon.timestream.jdbc=FINE` to the `logging.properties` file
3. Run application with arguments `-Djava.util.logging.config.file="logging.properties"`

#### Programmatically in the code
`public static void setLogLevel(Level level) {
Logger rootLogger = LogManager.getLogManager().getLogger("");
Handler[] handlers = rootLogger.getHandlers();
rootLogger.setLevel(level);
for (Handler handler : handlers) {
if(handler instanceof FileHandler) {
handler.setLevel(newLvl);
}
}`
}`

#### Logs example

21:23:51.255 [main] INFO software.amazon.timestream.jdbc.TimestreamConnection - Initializing the client.
21:23:51.256 [main] INFO software.amazon.timestream.jdbc.TimestreamConnection - Creating an AWSStaticCredentialsProvider.
Jul. 25, 2023 9:23:51 P.M. com.amazonaws.internal.DefaultServiceEndpointBuilder getServiceEndpoint
INFO: {query.timestream, us-west-2} was not found in region metadata, trying to construct an endpoint using the standard pattern for this region: region
21:23:53.191 [main] INFO software.amazon.timestream.jdbc.TimestreamStatement - Query ID: SOME_ID

### Known Issues
1. Timestream does not support fully qualified table names.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;

/**
Expand Down

0 comments on commit d9ce589

Please sign in to comment.