Skip to content

Commit d9ed90c

Browse files
Set Connection Leak Threshold & Added DEBUG Logs logging
1 parent e5c5be8 commit d9ed90c

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ build/
55
/config.json
66
/config
77
/purgeArchives
8+
/logs
89

910
# Eclipse settings
1011
.classpath

‎src/main/java/net/javadiscord/javabot/data/config/SystemsConfig.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public class SystemsConfig {
5959
public static class HikariConfig {
6060
private String jdbcUrl = "jdbc:h2:tcp://localhost:9122/./java_bot";
6161
private int maximumPoolSize = 5;
62+
private long leakDetectionThreshold = 10000;
6263
}
6364

6465
/**

‎src/main/java/net/javadiscord/javabot/data/h2db/DbHelper.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ private DbHelper() {
5454
var hikariConfigSource = config.getSystems().getHikariConfig();
5555
hikariConfig.setJdbcUrl(hikariConfigSource.getJdbcUrl());
5656
hikariConfig.setMaximumPoolSize(hikariConfigSource.getMaximumPoolSize());
57+
hikariConfig.setLeakDetectionThreshold(hikariConfigSource.getLeakDetectionThreshold());
5758
var ds = new HikariDataSource(hikariConfig);
5859
// Add a shutdown hook to close down the datasource and server when the JVM terminates.
5960
Runtime.getRuntime().addShutdownHook(new Thread(() -> {

‎src/main/resources/logback.xml‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<configuration>
3+
<timestamp key="timeOnLaunch" datePattern="yyyy'.'MM'.'dd'-'HH'.'mm'.'ss"/>
4+
35
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
6+
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
7+
<level>INFO</level>
8+
</filter>
49
<encoder>
510
<pattern>%d{dd.MM.yyyy HH:mm:ss} %boldCyan(%-34.-34thread) %red(%10.10X{jda.shard}) %boldGreen(%-15.-15logger{0}) %highlight(%-6level) %msg%n</pattern>
611
</encoder>
712
</appender>
813

9-
<root level="info">
14+
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
15+
<file>logs/log-${timeOnLaunch}.log</file>
16+
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
17+
<level>DEBUG</level>
18+
</filter>
19+
<immediateFlush>true</immediateFlush>
20+
<append>true</append>
21+
<encoder>
22+
<pattern>%d{dd.MM.yyyy HH:mm:ss} %-34.-34thread %10.10X{jda.shard} %-15.-15logger{0} %-6level %msg%n</pattern>
23+
</encoder>
24+
</appender>
25+
26+
<root level="debug">
1027
<appender-ref ref="STDOUT" />
1128
</root>
29+
30+
<logger name="com.zaxxer.hikari">
31+
<appender-ref ref="FILE" />
32+
</logger>
1233
</configuration>

0 commit comments

Comments
 (0)