Skip to content

Commit

Permalink
Add slf4j logback settings and initial logstash config (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
mw-ding authored Jun 19, 2018
1 parent 05e826a commit 3a35ced
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ dependencies {
// compile "io.springfox:springfox-swagger2:2.8.0"
// compile "javax.xml.bind:jaxb-api:2.3.0"

compile "net.logstash.logback:logstash-logback-encoder:4.11"
compile "ch.qos.logback:logback-classic:$logbackVersion"
compile "ch.qos.logback:logback-core:$logbackVersion"
compile "ch.qos.logback:logback-access:$logbackVersion"
compile "org.slf4j:slf4j-api:$slf4jVersion"

compile "com.google.protobuf:protobuf-java-util:$protocVersion"
compile "org.eclipse.jgit:org.eclipse.jgit:$jgitVersion"

Expand Down
5 changes: 5 additions & 0 deletions backend/src/main/java/castro/backend/Application.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package castro.backend;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand All @@ -19,7 +21,10 @@
@SpringBootApplication
//@EnableSwagger2
public class Application {
private static final Logger logger = LoggerFactory.getLogger(Application.class);

public static void main(String[] args) {
logger.debug("Hello, Castro.");
SpringApplication.run(Application.class, args);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class RepositoryApiController implements RepositoryApi {

@Override
public Repository repositoryImpl(String id) {
logger.debug("Repository {}", id);
return Repository.newBuilder().setDomain("github.com").setMainBranch("master").setRepositoryId(id).build();
}

Expand Down
23 changes: 23 additions & 0 deletions backend/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
</encoder>
</appender>

<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>127.0.0.1:5000</destination>

<!-- encoder is required -->
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>

<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="LOGSTASH" />
</root>

</configuration>
2 changes: 2 additions & 0 deletions config/logstash/config/logstash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node:
name: "dev"
15 changes: 15 additions & 0 deletions config/logstash/pipeline/logstash.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
input {
tcp {
port => 5000
codec => "json"
}
}

output {
elasticsearch {
hosts => [ "elasticsearch:9200" ]
}
stdout {
codec => json
}
}
13 changes: 13 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,17 @@ services:
# - 9300:9300 // when using tcp port
environment:
ES_JAVA_OPTS: "-Xms768m -Xmx768m"
restart: on-failure

logstash:
image: 'elastic/logstash:6.3.0'
volumes:
- ./config/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml
- ./config/logstash/pipeline/:/usr/share/logstash/pipeline/
ports:
- "5000:5000"
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
depends_on:
- elasticsearch
restart: on-failure
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ yarnVersion = 1.6.0

protocVersion = 3.5.1
jgitVersion = 5.0.0.201805301535-rc2

slf4jVersion = 1.7.25
logbackVersion = 1.2.3

0 comments on commit 3a35ced

Please sign in to comment.