Pom.XML
<dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.8</version> </dependency> <dependency> <groupId>org.graylog2</groupId> <artifactId>gelfclient</artifactId> <version>1.4.1</version> </dependency> <dependency> <groupId>org.graylog2.log4j2</groupId> <artifactId>log4j2-gelf</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-slf4j-impl</artifactId> <version>2.4.1</version> <scope>test</scope> </dependency> |
Log4j2.xml
▶위치는 당연히 main/resources 아래
server = graylog server IP port = Input 등록때 설정한 port <?xml version="1.0" encoding="UTF-8"?> <Configuration status="info" packages="org.graylog2.log4j2"> <Appenders> <GELF name="gelfAppender" server="192.168.0.190" port="12201" extractStacktrace="true" addExtendedInformation="true"> <PatternLayout> <pattern>%d %-5p [%t] %C{2} (%F:%L) - %m%n</pattern> </PatternLayout>
<!-- <KeyValuePair key="app" value="test app"/> <KeyValuePair key="foo" value="bar"/> <KeyValuePair key="jvm" value="${java:vm}"/> --> </GELF> <Console name="STDOUT" target="SYSTEM_OUT"> <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%level] [%thread] [%c{1.}] - %m%n"/> </Console> </Appenders> <Loggers> <Root level="info"> <AppenderRef ref="gelfAppender"/> <AppenderRef ref="STDOUT"/> </Root> </Loggers> </Configuration> |
Test Source
import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.odin.mqtt.RabbitmqProcess; import com.odin.remoteServer.RMIserver; public class App { static final Logger logg = LogManager.getLogger(App.class);
public static void main(String[] args){
logg.info("test test test"); 찍어보자
} } |
콘솔 확인
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/ksu/.m2/repository/org/slf4j/slf4j-log4j12/1.7.10/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/ksu/.m2/repository/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 2017-02-01 18:54:52.142 [INFO] [main] [c.o.m.App] - test test test INFO (logging.SLF4JLogger:71) - Cluster created with settings {hosts=[127.0.0.1:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500} INFO (mongo.MongoProcess:24) - MongoDB Connection
|
WEB 이동
▶Stream에서 규칙으로 걸러서 수집되는지 확인~해보고 정상이면 끝
'빅데이터' 카테고리의 다른 글
Kafka 설치(1) (0) | 2017.04.26 |
---|---|
ETL - Talend (0) | 2017.04.25 |
GrayLog (3) - 설치 (0) | 2017.04.20 |
GrayLog (2) - Install Elasticsearch (0) | 2017.04.20 |
GrayLog (1) - 설명 (0) | 2017.04.20 |