File tree Expand file tree Collapse file tree
java/com/baeldung/graylog Expand file tree Collapse file tree Original file line number Diff line number Diff line change 145145 <artifactId >chaos-monkey-spring-boot</artifactId >
146146 <version >${chaos.monkey.version} </version >
147147 </dependency >
148+
149+ <!-- for Graylog demo -->
150+ <dependency >
151+ <!-- forcing spring boot 1.x sing log4j was dropped in spring boot 1.4 and beyond -->
152+ <groupId >org.springframework.boot</groupId >
153+ <artifactId >spring-boot-starter-log4j</artifactId >
154+ <version >1.3.8.RELEASE</version >
155+ </dependency >
156+ <dependency >
157+ <groupId >org.graylog2</groupId >
158+ <artifactId >gelfj</artifactId >
159+ <version >1.1.16</version >
160+ <scope >compile</scope >
161+ </dependency >
148162 </dependencies >
149163
150164 <build >
224238 <git-commit-id-plugin .version>2.2.4</git-commit-id-plugin .version>
225239 </properties >
226240
227- </project >
241+ </project >
Original file line number Diff line number Diff line change 1+ package com .baeldung .graylog ;
2+
3+ import org .apache .log4j .Logger ;
4+ import org .springframework .boot .SpringApplication ;
5+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
6+
7+ @ SpringBootApplication
8+ public class GraylogDemoApplication {
9+
10+ private final static Logger LOG =
11+ Logger .getLogger (GraylogDemoApplication .class );
12+
13+ public static void main (String [] args ) {
14+ SpringApplication .run (GraylogDemoApplication .class , args );
15+ LOG .info ("Hello from Spring Boot" );
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!DOCTYPE log4j:configuration SYSTEM "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
3+ <log4j : configuration >
4+ <appender name =" stdout" class =" org.apache.log4j.ConsoleAppender" >
5+ <layout class =" org.apache.log4j.PatternLayout" >
6+ <param name =" ConversionPattern" value =" %d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } [%t] --- %-40.40logger{39} : %m%n" />
7+ </layout >
8+ </appender >
9+ <appender name =" graylog" class =" org.graylog2.log.GelfAppender" >
10+ <param name =" graylogHost" value =" 18.217.253.212" />
11+ <param name =" originHost" value =" localhost" />
12+ <param name =" graylogPort" value =" 12201" />
13+ <param name =" extractStacktrace" value =" true" />
14+ <param name =" addExtendedInformation" value =" true" />
15+ <param name =" facility" value =" log4j" />
16+ <param name =" Threshold" value =" DEBUG" />
17+ <param name =" additionalFields" value =" {'environment': 'DEV', 'application': 'GraylogDemoApplication'}" />
18+ </appender >
19+ <root >
20+ <priority value =" DEBUG" />
21+ <appender-ref ref =" stdout" />
22+ <appender-ref ref =" graylog" />
23+ </root >
24+ </log4j : configuration >
You can’t perform that action at this time.
0 commit comments