[GRIFFIN-273] Griffin Service with user-defined log4j2 configuration

Currently, the Griffin service module use spring-boot default log4j2 configuration.

This approach is not easy to change the config for debugging and add new appender such as
RollingFile

Author: Johnnie <joohnnie.z@gmail.com>
Author: Johnnie Zhang <yixizhang@ebay.com>

Closes #518 from joohnnie/GRIFFIN-273.
diff --git a/.gitignore b/.gitignore
index a09422a..5e0ef52 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,4 +41,5 @@
 
 .vscode
 
-environment.local.ts
\ No newline at end of file
+environment.local.ts
+logs/
\ No newline at end of file
diff --git a/service/pom.xml b/service/pom.xml
index 8f51587..3c4ed80 100644
--- a/service/pom.xml
+++ b/service/pom.xml
@@ -84,6 +84,10 @@
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-log4j2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-jpa</artifactId>
             <exclusions>
                 <exclusion>
@@ -147,6 +151,10 @@
                     <groupId>javax.servlet</groupId>
                     <artifactId>servlet-api</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
         <dependency>
@@ -195,6 +203,10 @@
                     <groupId>org.mortbay.jetty</groupId>
                     <artifactId>servlet-api-2.5</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
 
@@ -203,6 +215,12 @@
             <groupId>io.confluent</groupId>
             <artifactId>kafka-schema-registry-client</artifactId>
             <version>${confluent.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <!--schedule-->
diff --git a/service/src/main/java/org/apache/griffin/core/GriffinWebApplication.java b/service/src/main/java/org/apache/griffin/core/GriffinWebApplication.java
index 4ed4773..33fc049 100644
--- a/service/src/main/java/org/apache/griffin/core/GriffinWebApplication.java
+++ b/service/src/main/java/org/apache/griffin/core/GriffinWebApplication.java
@@ -35,8 +35,8 @@
             .getLogger(GriffinWebApplication.class);
 
     public static void main(String[] args) {
-        LOGGER.info("application start");
         SpringApplication.run(GriffinWebApplication.class, args);
+        LOGGER.info("application started");
     }
 
     @Bean
diff --git a/service/src/main/resources/application-dev.properties b/service/src/main/resources/application-dev.properties
index d310ce3..14bd198 100644
--- a/service/src/main/resources/application-dev.properties
+++ b/service/src/main/resources/application-dev.properties
@@ -25,4 +25,6 @@
 spring.datasource.schema=classpath:init_quartz_h2.sql
 # enable h2 console, default path: http://localhost:8080/h2-console/
 spring.h2.console.enabled=true
-spring.jpa.show-sql=true
\ No newline at end of file
+spring.jpa.show-sql=true
+
+logging.file=logs/griffin-service.log
\ No newline at end of file
diff --git a/service/src/main/resources/application-docker.properties b/service/src/main/resources/application-docker.properties
index 8c7806e..2a0bf2b 100644
--- a/service/src/main/resources/application-docker.properties
+++ b/service/src/main/resources/application-docker.properties
@@ -80,3 +80,5 @@
 livy.task.appId.retry.count=3
 # yarn url
 yarn.uri=http://10.148.215.23:38088
+
+logging.file=logs/griffin-service.log
\ No newline at end of file
diff --git a/service/src/main/resources/application-mysql.properties b/service/src/main/resources/application-mysql.properties
index 0b124ef..e80534b 100644
--- a/service/src/main/resources/application-mysql.properties
+++ b/service/src/main/resources/application-mysql.properties
@@ -25,3 +25,5 @@
 spring.datasource.driver-class-name=com.mysql.jdbc.Driver
 spring.jpa.show-sql=true
 spring.jpa.hibernate.ddl-auto=update
+
+logging.file=logs/griffin-service.log
\ No newline at end of file
diff --git a/service/src/main/resources/application-prod.properties b/service/src/main/resources/application-prod.properties
index b977276..29afae5 100644
--- a/service/src/main/resources/application-prod.properties
+++ b/service/src/main/resources/application-prod.properties
@@ -65,4 +65,6 @@
 livy.task.submit.interval.second=3
 livy.task.appId.retry.count=3
 # yarn url
-yarn.uri=http://localhost:8088
\ No newline at end of file
+yarn.uri=http://localhost:8088
+
+logging.file=logs/griffin-service.log
\ No newline at end of file
diff --git a/service/src/main/resources/application.properties b/service/src/main/resources/application.properties
index c01c270..ccef9dd 100644
--- a/service/src/main/resources/application.properties
+++ b/service/src/main/resources/application.properties
@@ -77,3 +77,5 @@
 yarn.uri=http://localhost:8088
 # griffin event listener
 internal.event.listeners=GriffinJobEventHook
+
+logging.file=logs/griffin-service.log
\ No newline at end of file
diff --git a/service/src/main/resources/log4j2-spring.xml b/service/src/main/resources/log4j2-spring.xml
new file mode 100644
index 0000000..c021b4a
--- /dev/null
+++ b/service/src/main/resources/log4j2-spring.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="WARN">
+    <Properties>
+        <Property name="PID">????</Property>
+        <Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property>
+        <Property name="LOG_LEVEL_PATTERN">%5p</Property>
+        <Property name="CONSOLE_LOG_PATTERN">%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{${LOG_LEVEL_PATTERN}} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%15.15t]}{faint} %clr{%-40.40c{1.}[%L]}{cyan}  %clr{:}{faint} %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
+        <Property name="FILE_LOG_PATTERN">%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN} ${sys:PID} --- [%t] %-40.40c{1.}[%L] : %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
+    </Properties>
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT" follow="true">
+            <PatternLayout pattern="${sys:CONSOLE_LOG_PATTERN}" />
+        </Console>
+        <RollingFile name="File" fileName="${sys:LOG_FILE}"
+                     filePattern="logs/$${date:yyyy-MM}/application-%d{yyyy-MM-dd-HH}-%i.log.gz">
+            <PatternLayout>
+                <Pattern>${sys:FILE_LOG_PATTERN}</Pattern>
+            </PatternLayout>
+            <Policies>
+                <SizeBasedTriggeringPolicy size="10 MB" />
+            </Policies>
+            <DefaultRollOverStrategy max = "10"/>
+        </RollingFile>
+    </Appenders>
+    <Loggers>
+        <Logger name="org.apache.catalina.startup.DigesterFactory" level="error" />
+        <Logger name="org.apache.catalina.util.LifecycleBase" level="error" />
+        <Logger name="org.apache.coyote.http11.Http11NioProtocol" level="warn" />
+        <logger name="org.apache.sshd.common.util.SecurityUtils" level="warn"/>
+        <Logger name="org.apache.tomcat.util.net.NioSelectorPool" level="warn" />
+        <Logger name="org.crsh.plugin" level="warn" />
+        <logger name="org.crsh.ssh" level="warn"/>
+        <Logger name="org.eclipse.jetty.util.component.AbstractLifeCycle" level="error" />
+        <Logger name="org.hibernate.validator.internal.util.Version" level="warn" />
+        <logger name="org.springframework.boot.actuate.autoconfigure.CrshAutoConfiguration" level="warn"/>
+        <logger name="org.springframework.boot.actuate.endpoint.jmx" level="warn"/>
+        <logger name="org.thymeleaf" level="warn"/>
+        <Root level="info">
+            <AppenderRef ref="Console" />
+            <AppenderRef ref="File" />
+        </Root>
+    </Loggers>
+</Configuration>
diff --git a/service/src/test/resources/application.properties b/service/src/test/resources/application.properties
index 86d5316..7864be9 100644
--- a/service/src/test/resources/application.properties
+++ b/service/src/test/resources/application.properties
@@ -59,3 +59,5 @@
 # elasticsearch.password = password
 # griffin event listener
 internal.event.listeners=GriffinJobEventHook,GriffinTestJobEventHook
+
+logging.file=logs/griffin-service.log
\ No newline at end of file