1.配置plumelog.yml
version: '3'
services:plumelog:image: registry.cn-hangzhou.aliyuncs.com/k8s-xiyan/plumelog:3.5.3container_name: plumelogports:- "8891:8891"environment:plumelog.model: redisplumelog.queue.redis.redisHost: redis:6379plumelog.queue.redis.redisPassWord: W0CNwUW12eZe3sXynXSXIuqYpH3MBh7nplumelog.queue.redis.redisDb: 15plumelog.es.esHosts: elasticsearch:9200admin.log.keepDays: 7admin.log.trace.keepDays: 7admin.password: 123456login.username: adminlogin.password: admin
2.执行
docker-compose -f plumelog.yml up -d
3.JAVA整合
<dependency><groupId>com.plumelog</groupId><artifactId>plumelog-logback</artifactId><version>3.5.3</version></dependency>
4.bootstrap.yml 配置
plumelog:env: devredis-host: 172.16.2.43:6379redis-auth: W0CNwUW12eZe3sXynXSXIuqYpH3MBh7n
5.logback-spring.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false"><property name="log.path" value="/opt/service/logs/portrait-model"/><property name="log.pattern"value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] %-5level [%thread][%X{traceId}][%X{requestUser}][%X{requestUrl}] %logger{40}:%L - %msg%n"/><appender name="console" class="ch.qos.logback.core.ConsoleAppender"><encoder><pattern>${log.pattern}</pattern></encoder></appender><appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender"><file>${log.path}/info.log</file><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><fileNamePattern>${log.path}/info-%d{yyyy-MM-dd}-%i.log</fileNamePattern><timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><maxFileSize>512MB</maxFileSize></timeBasedFileNamingAndTriggeringPolicy><maxHistory>7</maxHistory></rollingPolicy><encoder><pattern>${log.pattern}</pattern></encoder><filter class="ch.qos.logback.classic.filter.LevelFilter"><level>INFO</level><onMatch>ACCEPT</onMatch><onMismatch>DENY</onMismatch></filter></appender><appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender"><file>${log.path}/error.log</file><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><fileNamePattern>${log.path}/error-%d{yyyy-MM-dd}-%i.log</fileNamePattern><timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><maxFileSize>512MB</maxFileSize></timeBasedFileNamingAndTriggeringPolicy><maxHistory>7</maxHistory></rollingPolicy><encoder><pattern>${log.pattern}</pattern></encoder><filter class="ch.qos.logback.classic.filter.LevelFilter"><level>ERROR</level><onMatch>ACCEPT</onMatch><onMismatch>DENY</onMismatch></filter></appender><springProperty scope="context" name="plumelog.appName" source="spring.application.name"/><springProperty scope="context" name="plumelog.redisHost" source="plumelog.redis-host"/><springProperty scope="context" name="plumelog.redisAuth" source="plumelog.redis-auth"/><springProperty scope="context" name="plumelog.env" source="plumelog.env"/><appender name="plumelog" class="com.plumelog.logback.appender.RedisAppender"><appName>${plumelog.appName}</appName><redisHost>${plumelog.redisHost}</redisHost><redisAuth>${plumelog.redisAuth}</redisAuth><redisDb>15</redisDb><env>${plumelog.env}</env></appender><root level="info"><appender-ref ref="console"/><appender-ref ref="file_info"/><appender-ref ref="file_error"/><appender-ref ref="plumelog"/></root><logger name="com.qxsk" level="info"/><logger name="org.apache" level="INFO"/><logger name="org.springframework" level="info"/>
</configuration>
6.浏览器访问