com.houkunlin.system.applog.AppLogHandlerAmqpImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of system-applog-starter Show documentation
Show all versions of system-applog-starter Show documentation
使用 AppLog 注解记录日志信息,或者使用 AppLoggerFactory.getLogger(name) 这种类似 Slf4J 的形式记录日志信息。
需要自行监听 AppLogEvent 事件去保存日志信息。
package com.houkunlin.system.applog;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.scheduling.annotation.Async;
/**
* 把应用日志信息推送到 RabbitMQ 消息队列
*
* @author HouKunLin
*/
@RequiredArgsConstructor
public class AppLogHandlerAmqpImpl implements AppLogHandler {
private final AppLogProperties appLogProperties;
private final AmqpTemplate amqpTemplate;
@Async
@Override
public void handle(AppLogInfo entity) {
amqpTemplate.convertAndSend(appLogProperties.getMqExchange(),
appLogProperties.getMqRoutingKey(),
entity);
}
@Override
public void handle(AppLogInfo entity, Object oldObject, Object newObject) {
amqpTemplate.convertAndSend(appLogProperties.getMqExchange(),
appLogProperties.getMqRoutingKey(),
entity);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy