fix(log):replace log4j by logback (#45)

diff --git a/.gitignore b/.gitignore
index 73dfeae..88d5751 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,5 @@
 *.txt
 target/
 *.versionsBackup
+logs/
 
diff --git a/backend/pom.xml b/backend/pom.xml
index a7d67a9..2ce0471 100644
--- a/backend/pom.xml
+++ b/backend/pom.xml
@@ -38,6 +38,8 @@
     <java.version>1.8</java.version>
     <skipTests>true</skipTests>
     <spotless.version>2.4.2</spotless.version>
+    <slf4j.version>1.7.12</slf4j.version>
+    <logback.version>1.2.11</logback.version>
   </properties>
 
 
@@ -61,8 +63,14 @@
     </dependency>
 
     <dependency>
-      <groupId>org.springframework.boot</groupId>
-      <artifactId>spring-boot-starter-log4j2</artifactId>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+      <version>${slf4j.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+      <version>${logback.version}</version>
     </dependency>
 
 
diff --git a/backend/src/main/resources/application-dev.properties b/backend/src/main/resources/application-dev.properties
index 121476b..e3d3dd7 100644
--- a/backend/src/main/resources/application-dev.properties
+++ b/backend/src/main/resources/application-dev.properties
@@ -18,7 +18,7 @@
 #
 
 # Designate the log configuration file
-logging.config=classpath:log4j2.xml
+logging.classpath=logback.xml
 
 # Set port and context path
 server.port=9090
diff --git a/backend/src/main/resources/application-prod.properties b/backend/src/main/resources/application-prod.properties
index 66a5d2b..4a3a4ff 100644
--- a/backend/src/main/resources/application-prod.properties
+++ b/backend/src/main/resources/application-prod.properties
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-logging.config=classpath:log4j2-prod.xml
+logging.classpath=logback.xml
 
 server.port=9089
 server.servlet.context-path=/api
diff --git a/backend/src/main/resources/application-test.properties b/backend/src/main/resources/application-test.properties
index f661868..d6b1f51 100644
--- a/backend/src/main/resources/application-test.properties
+++ b/backend/src/main/resources/application-test.properties
@@ -17,8 +17,7 @@
 # under the License.
 #
 
-logging.config=classpath:log4j2.xml
-
+logging.classpath=logback.xml
 server.port=8079
 server.servlet.context-path=/api
 
diff --git a/backend/src/main/resources/log4j2-prod.xml b/backend/src/main/resources/log4j2-prod.xml
deleted file mode 100644
index 9bea303..0000000
--- a/backend/src/main/resources/log4j2-prod.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<configuration status="ERROR">
-
-    <Properties>
-        <property name="app">IoTDB-Workbench</property>
-        <property name="log.root.level">INFO</property>
-        <property name="log.home">/data/applogs/app-prod</property>
-        <property name="log.default.pattern">%-d{yyyy-MM-dd HH:mm:ss.SSS} [%p] [${app}] %l %m%n</property>
-        <property name="log.stats.pattern">%m%n</property>
-    </Properties>
-
-    <appenders>
-        <Console name="STDOUT" target="SYSTEM_OUT">
-            <PatternLayout>
-                <Pattern>${log.default.pattern}</Pattern>
-            </PatternLayout>
-        </Console>
-
-        <RollingFile name="ROLLING_DEBUG" fileName="${log.home}/${app}_debug.log"
-                     filePattern="${log.home}/debug.log.%i">
-            <PatternLayout>
-                <Pattern>${log.default.pattern}</Pattern>
-            </PatternLayout>
-            <Policies>
-                <SizeBasedTriggeringPolicy size="100 MB" />
-            </Policies>
-            <DefaultRolloverStrategy max="10"/>
-            <!--<DirectWriteRolloverStrategy maxFiles="10"/>-->
-            <Filters>
-                <ThresholdFilter level="DEBUG" onMatch="ACCEPT"/>
-            </Filters>
-        </RollingFile>
-
-        <RollingFile name="ROLLING_INFO" fileName="${log.home}/${app}_info.log"
-                     filePattern="${log.home}/info.log.%i">
-            <PatternLayout>
-                <Pattern>${log.default.pattern}</Pattern>
-            </PatternLayout>
-            <Policies>
-                <SizeBasedTriggeringPolicy size="100 MB" />
-            </Policies>
-            <DefaultRolloverStrategy max="10"/>
-            <Filters>
-                <ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL"/>
-                <ThresholdFilter level="INFO" onMatch="ACCEPT"/>
-            </Filters>
-        </RollingFile>
-
-        <RollingFile name="ROLLING_WARN" fileName="${log.home}/${app}_warn.log"
-                     filePattern="${log.home}/warn.log.%i">
-            <PatternLayout>
-                <Pattern>${log.default.pattern}</Pattern>
-            </PatternLayout>
-            <Policies>
-                <SizeBasedTriggeringPolicy size="100 MB" />
-            </Policies>
-            <DefaultRolloverStrategy max="10"/>
-            <Filters>
-                <ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="NEUTRAL"/>
-                <ThresholdFilter level="WARN" onMatch="ACCEPT"/>
-            </Filters>
-        </RollingFile>
-
-        <RollingFile name="ROLLING_ERROR" fileName="${log.home}/${app}_error.log"
-                     filePattern="${log.home}/error.log.%i">
-            <PatternLayout>
-                <Pattern>${log.default.pattern}</Pattern>
-            </PatternLayout>
-            <Policies>
-                <SizeBasedTriggeringPolicy size="100 MB" />
-            </Policies>
-            <DefaultRolloverStrategy max="10"/>
-            <!--<DirectWriteRolloverStrategy maxFiles="10"/>-->
-            <Filters>
-                <ThresholdFilter level="ERROR" onMatch="ACCEPT"/>
-            </Filters>
-        </RollingFile>
-
-
-
-    </appenders>
-
-    <loggers>
-        <!--level: ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF -->
-        <Root level="${log.root.level}">
-            <AppenderRef ref="STDOUT"/>
-            <AppenderRef ref="ROLLING_INFO"/>
-            <AppenderRef ref="ROLLING_WARN"/>
-            <AppenderRef ref="ROLLING_ERROR"/>
-            <!--<AppenderRef ref="ROLLING_DEBUG"/>-->
-        </Root>
-
-
-        <!--<logger name="com.alibaba" level="ERROR"/>-->
-        <!--<logger name="org" level="ERROR"/>-->
-
-    </loggers>
-
-</configuration>
-
diff --git a/backend/src/main/resources/log4j2.xml b/backend/src/main/resources/log4j2.xml
deleted file mode 100644
index c4660f6..0000000
--- a/backend/src/main/resources/log4j2.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one
-  ~ or more contributor license agreements.  See the NOTICE file
-  ~ distributed with this work for additional information
-  ~ regarding copyright ownership.  The ASF licenses this file
-  ~ to you under the Apache License, Version 2.0 (the
-  ~ "License"); you may not use this file except in compliance
-  ~ with the License.  You may obtain a copy of the License at
-  ~
-  ~   http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing,
-  ~ software distributed under the License is distributed on an
-  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  ~ KIND, either express or implied.  See the License for the
-  ~ specific language governing permissions and limitations
-  ~ under the License.
-  -->
-
-<configuration status="ERROR">
-
-    <Properties>
-        <property name="app">IoTDB-Workbench</property>
-        <property name="log.root.level">INFO</property>
-        <property name="log.home">/data/applogs/app-test</property>
-        <property name="log.default.pattern">%-d{yyyy-MM-dd HH:mm:ss.SSS} [%p] [${app}] %l %m%n</property>
-        <property name="log.stats.pattern">%m%n</property>
-    </Properties>
-
-    <appenders>
-        <Console name="STDOUT" target="SYSTEM_OUT">
-            <PatternLayout>
-                <Pattern>${log.default.pattern}</Pattern>
-            </PatternLayout>
-        </Console>
-
-        <RollingFile name="ROLLING_DEBUG" fileName="${log.home}/${app}_debug.log"
-                     filePattern="${log.home}/debug.log.%i">
-            <PatternLayout>
-                <Pattern>${log.default.pattern}</Pattern>
-            </PatternLayout>
-            <Policies>
-                <SizeBasedTriggeringPolicy size="100 MB" />
-            </Policies>
-            <DefaultRolloverStrategy max="10"/>
-            <!--<DirectWriteRolloverStrategy maxFiles="10"/>-->
-            <Filters>
-                <ThresholdFilter level="DEBUG" onMatch="ACCEPT"/>
-            </Filters>
-        </RollingFile>
-
-        <RollingFile name="ROLLING_INFO" fileName="${log.home}/${app}_info.log"
-                     filePattern="${log.home}/info.log.%i">
-            <PatternLayout>
-                <Pattern>${log.default.pattern}</Pattern>
-            </PatternLayout>
-            <Policies>
-                <SizeBasedTriggeringPolicy size="100 MB" />
-            </Policies>
-            <DefaultRolloverStrategy max="10"/>
-            <Filters>
-                <ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL"/>
-                <ThresholdFilter level="INFO" onMatch="ACCEPT"/>
-            </Filters>
-        </RollingFile>
-
-        <RollingFile name="ROLLING_WARN" fileName="${log.home}/${app}_warn.log"
-                     filePattern="${log.home}/warn.log.%i">
-            <PatternLayout>
-                <Pattern>${log.default.pattern}</Pattern>
-            </PatternLayout>
-            <Policies>
-                <SizeBasedTriggeringPolicy size="100 MB" />
-            </Policies>
-            <DefaultRolloverStrategy max="10"/>
-            <Filters>
-                <ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="NEUTRAL"/>
-                <ThresholdFilter level="WARN" onMatch="ACCEPT"/>
-            </Filters>
-        </RollingFile>
-
-        <RollingFile name="ROLLING_ERROR" fileName="${log.home}/${app}_error.log"
-                     filePattern="${log.home}/error.log.%i">
-            <PatternLayout>
-                <Pattern>${log.default.pattern}</Pattern>
-            </PatternLayout>
-            <Policies>
-                <SizeBasedTriggeringPolicy size="100 MB" />
-            </Policies>
-            <DefaultRolloverStrategy max="10"/>
-            <!--<DirectWriteRolloverStrategy maxFiles="10"/>-->
-            <Filters>
-                <ThresholdFilter level="ERROR" onMatch="ACCEPT"/>
-            </Filters>
-        </RollingFile>
-
-
-
-    </appenders>
-
-    <loggers>
-        <!--level: ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF -->
-        <Root level="${log.root.level}">
-            <AppenderRef ref="STDOUT"/>
-            <AppenderRef ref="ROLLING_INFO"/>
-            <AppenderRef ref="ROLLING_WARN"/>
-            <AppenderRef ref="ROLLING_ERROR"/>
-            <!--<AppenderRef ref="ROLLING_DEBUG"/>-->
-        </Root>
-
-
-        <!--<logger name="com.alibaba" level="ERROR"/>-->
-        <!--<logger name="org" level="ERROR"/>-->
-
-    </loggers>
-
-</configuration>
-
diff --git a/backend/src/main/resources/logback.xml b/backend/src/main/resources/logback.xml
new file mode 100644
index 0000000..688f52e
--- /dev/null
+++ b/backend/src/main/resources/logback.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<configuration scan="true" scanPeriod="60 seconds">
+
+    <property name="LOG_HOME" value="./logs" />
+    <property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n" />
+
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_HOME}/workbench_debug.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <FileNamePattern>${LOG_HOME}/workbench-debug.%d{yyyyMMdd}.%i.log</FileNamePattern>
+            <MaxHistory>30</MaxHistory>
+            <maxFileSize>10MB</maxFileSize>
+            <totalSizeCap>512MB</totalSizeCap>
+        </rollingPolicy>
+        <append>true</append>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>${FILE_LOG_PATTERN}</pattern>
+            <charset>utf-8</charset>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>DEBUG</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>NEUTRAL</onMismatch>
+        </filter>
+    </appender>
+
+    <appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_HOME}/workbench_warn.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <FileNamePattern>${LOG_HOME}/workbench-warn.%d{yyyyMMdd}.%i.log</FileNamePattern>
+            <MaxHistory>30</MaxHistory>
+            <maxFileSize>10MB</maxFileSize>
+            <totalSizeCap>512MB</totalSizeCap>
+        </rollingPolicy>
+        <append>true</append>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>${FILE_LOG_PATTERN}</pattern>
+            <charset>utf-8</charset>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>WARN</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_HOME}/workbench_error.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <FileNamePattern>${LOG_HOME}/workbench-error.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
+            <MaxHistory>30</MaxHistory>
+            <maxFileSize>10MB</maxFileSize>
+            <totalSizeCap>512MB</totalSizeCap>
+        </rollingPolicy>
+        <append>true</append>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>${FILE_LOG_PATTERN}</pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>ERROR</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${LOG_HOME}/workbench_info.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+            <FileNamePattern>${LOG_HOME}/workbench-info.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
+            <MaxHistory>30</MaxHistory>
+            <maxFileSize>10MB</maxFileSize>
+            <totalSizeCap>512MB</totalSizeCap>
+        </rollingPolicy>
+        <append>true</append>
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
+            <pattern>${FILE_LOG_PATTERN}</pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>INFO</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>NEUTRAL</onMismatch>
+        </filter>
+    </appender>
+
+    <logger name="com.apache.ibatis" level="ERROR"/>
+    <logger name="java.sql.Connection" level="ERROR"/>
+    <logger name="java.sql.Statement" level="ERROR"/>
+    <logger name="java.sql.PreparedStatement" level="ERROR"/>
+
+    <root level="INFO">
+        <appender-ref ref="STDOUT" />
+        <appender-ref ref="INFO"/>
+        <appender-ref ref="DEBUG"/>
+        <appender-ref ref="ERROR"/>
+    </root>
+</configuration>