Initial graylog + spring boot demo (#5299)
* Initial graylog + spring boot demo * Move Graylog demo into existing spring-boot module
This commit is contained in:
		
							parent
							
								
									317ed150a1
								
							
						
					
					
						commit
						b343e82095
					
				| @ -145,6 +145,20 @@ | |||||||
|             <artifactId>chaos-monkey-spring-boot</artifactId> |             <artifactId>chaos-monkey-spring-boot</artifactId> | ||||||
|             <version>${chaos.monkey.version}</version> |             <version>${chaos.monkey.version}</version> | ||||||
|         </dependency> |         </dependency> | ||||||
|  | 
 | ||||||
|  |         <!-- for Graylog demo --> | ||||||
|  |         <dependency> | ||||||
|  |             <!-- forcing spring boot 1.x sing log4j was dropped in spring boot 1.4 and beyond --> | ||||||
|  |             <groupId>org.springframework.boot</groupId> | ||||||
|  |             <artifactId>spring-boot-starter-log4j</artifactId> | ||||||
|  |             <version>1.3.8.RELEASE</version> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.graylog2</groupId> | ||||||
|  |             <artifactId>gelfj</artifactId> | ||||||
|  |             <version>1.1.16</version> | ||||||
|  |             <scope>compile</scope> | ||||||
|  |         </dependency> | ||||||
|     </dependencies> |     </dependencies> | ||||||
| 
 | 
 | ||||||
|     <build> |     <build> | ||||||
|  | |||||||
| @ -0,0 +1,17 @@ | |||||||
|  | package com.baeldung.graylog; | ||||||
|  | 
 | ||||||
|  | import org.apache.log4j.Logger; | ||||||
|  | import org.springframework.boot.SpringApplication; | ||||||
|  | import org.springframework.boot.autoconfigure.SpringBootApplication; | ||||||
|  | 
 | ||||||
|  | @SpringBootApplication | ||||||
|  | public class GraylogDemoApplication { | ||||||
|  | 
 | ||||||
|  |     private final static Logger LOG = | ||||||
|  |             Logger.getLogger(GraylogDemoApplication.class); | ||||||
|  | 
 | ||||||
|  |     public static void main(String[] args) { | ||||||
|  |         SpringApplication.run(GraylogDemoApplication.class, args); | ||||||
|  |         LOG.info("Hello from Spring Boot"); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										24
									
								
								spring-boot/src/main/resources/log4j.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								spring-boot/src/main/resources/log4j.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8" ?> | ||||||
|  | <!DOCTYPE log4j:configuration SYSTEM "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd"> | ||||||
|  | <log4j:configuration> | ||||||
|  |     <appender name="stdout" class="org.apache.log4j.ConsoleAppender"> | ||||||
|  |         <layout class="org.apache.log4j.PatternLayout"> | ||||||
|  |             <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } [%t] --- %-40.40logger{39} : %m%n"/> | ||||||
|  |         </layout> | ||||||
|  |     </appender> | ||||||
|  |     <appender name="graylog" class="org.graylog2.log.GelfAppender"> | ||||||
|  |         <param name="graylogHost" value="18.217.253.212"/> | ||||||
|  |         <param name="originHost" value="localhost"/> | ||||||
|  |         <param name="graylogPort" value="12201"/> | ||||||
|  |         <param name="extractStacktrace" value="true"/> | ||||||
|  |         <param name="addExtendedInformation" value="true"/> | ||||||
|  |         <param name="facility" value="log4j"/> | ||||||
|  |         <param name="Threshold" value="DEBUG"/> | ||||||
|  |         <param name="additionalFields" value="{'environment': 'DEV', 'application': 'GraylogDemoApplication'}"/> | ||||||
|  |     </appender> | ||||||
|  |     <root> | ||||||
|  |         <priority value="DEBUG"/> | ||||||
|  |         <appender-ref ref="stdout"/> | ||||||
|  |         <appender-ref ref="graylog"/> | ||||||
|  |     </root> | ||||||
|  | </log4j:configuration> | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user