更高的负载能力
version: '3.6'
services:
syslog:
image: lscr.io/linuxserver/syslog-ng:latest
container_name: syslog-ng
ports:
- 514:5514/udp
- 601:6601/tcp
- 6514:6514/tcp
volumes:
- ./data/config:/config
- ./data/log:/var/log #optional
restart: unless-stopped
docker-compose -f docker-compose.yml up -d
down
docker-compose -f docker-compose.yml down
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>springboot-demo</artifactId>
<groupId>com.et</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>syslog</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
</dependencies>
</project>
package com.et.syslog.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
public class HelloWorldController {
private final Logger logger = LoggerFactory.getLogger(HelloWorldController.class);
@RequestMapping("/hello")
public Map<String, Object> showHelloWorld(@RequestParam("n") String name){
logger.info("Say hello to {}", name);
Map<String, Object> map = new HashMap<>();
map.put("msg", "HelloWorld");
return map;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT">
<PatternLayout
pattern="%style{%date{DEFAULT}}{yellow} %highlight{%-5level}{FATAL=bg_red, ERROR=red, WARN=yellow, INFO=green} %message%n"/>
</Console>
<Syslog name="Syslog" format="RFC5424" host="localhost" port="514"
protocol="UDP" appName="liuhaihua.cn" facility="LOCAL0" />
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="ConsoleAppender"/>
<AppenderRef ref="Syslog"/>
</Root>
</Loggers>
</Configuration>