-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #334 from iExecBlockchainComputing/graylog
Graylog
- Loading branch information
Showing
5 changed files
with
76 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/com/iexec/core/log/IexecGelfLogbackAppender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.iexec.core.log; | ||
|
||
import biz.paluch.logging.gelf.logback.GelfLogbackAppender; | ||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
import com.iexec.core.chain.CredentialsService; | ||
import org.springframework.beans.BeansException; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
import org.springframework.lang.NonNull; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class IexecGelfLogbackAppender extends GelfLogbackAppender implements ApplicationContextAware { | ||
|
||
private static String address; | ||
|
||
public IexecGelfLogbackAppender() { | ||
super(); | ||
} | ||
|
||
/* | ||
* Graylog note: The `originHost` will only contain what we want after CredentialService is loaded. | ||
* | ||
* Very first logs will have: | ||
* originHost=user@user.com | ||
* Next logs will have: | ||
* originHost=0x12..34 | ||
* | ||
* */ | ||
@Override | ||
protected void append(ILoggingEvent event) { | ||
if (address != null) { | ||
gelfMessageAssembler.setOriginHost(address); | ||
} | ||
super.append(event); | ||
} | ||
|
||
@Override | ||
public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException { | ||
CredentialsService credentialsService = (CredentialsService) applicationContext | ||
.getAutowireCapableBeanFactory().getBean("credentialsService"); | ||
address = credentialsService.getCredentials().getAddress(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<!-- Default --> | ||
<property name="LOG_LEVEL" value="${IEXEC_LOG_LEVEL:-INFO}"/> | ||
<include resource="org/springframework/boot/logging/logback/base.xml"/> | ||
<logger name="org.springframework.web" level="${LOG_LEVEL}"/> | ||
|
||
<!-- Graylog --> | ||
<springProperty name="graylogHost" source="graylog.host"/> | ||
<springProperty name="graylogPort" source="graylog.port"/> | ||
<appender name="gelf" class="com.iexec.core.log.IexecGelfLogbackAppender"> | ||
<host>${graylogHost}</host> | ||
<port>${graylogPort}</port> | ||
</appender> | ||
|
||
<root level="${LOG_LEVEL}"> | ||
<appender-ref ref="gelf"/> | ||
</root> | ||
|
||
</configuration> |
This file was deleted.
Oops, something went wrong.