Logging Thorntail(wldfly swarm)记录到Greylog
我如何才能将wildfly swarm日志记录到greylog,或者换句话说:以gelf格式进行日志记录?已经有人这样做了吗 graylog市场上似乎只有FramWorkers与log4j()或logback一起工作,而不是与jboss日志系统一起工作。从其他问题来看,我假设不可能将thorntail配置为使用log4j进行日志记录(无论如何,这会感觉有点错误:通过jboss进行管道日志记录,登录到log4j以将其导入gelf…) 底层的需求是我想要停靠我的swarm应用程序,并使用greylog作为集中式日志记录。我知道我可以将docker配置为登录gelf,但这意味着我无法控制应用程序中的扩展gelf函数,对吗Logging Thorntail(wldfly swarm)记录到Greylog,logging,graylog2,wildfly-swarm,gelf,Logging,Graylog2,Wildfly Swarm,Gelf,我如何才能将wildfly swarm日志记录到greylog,或者换句话说:以gelf格式进行日志记录?已经有人这样做了吗 graylog市场上似乎只有FramWorkers与log4j()或logback一起工作,而不是与jboss日志系统一起工作。从其他问题来看,我假设不可能将thorntail配置为使用log4j进行日志记录(无论如何,这会感觉有点错误:通过jboss进行管道日志记录,登录到log4j以将其导入gelf…) 底层的需求是我想要停靠我的swarm应用程序,并使用greylo
从thorntail/swarm实现集中日志记录的首选方法是什么?是的,可以将日志发送到thorntail中的graylog,因为有些人为我们实现了与jboss兼容的gelf日志处理程序。一些限制可能是您使用的日志框架。我不得不通过slf4j使用jboss记录器,没有花更多的时间让log4j运行。也许你会发现这是如何实现的 我在哪里可以获得与jboss兼容的gelf日志处理程序? 在这里,您可以找到支持gelf格式的jboss兼容日志处理程序的git存储库 如何配置日志处理程序? 有关此日志处理程序的文档,请参见以下链接 如何将其集成到thorntail中? 为此,你必须做一些工作 1.将依赖项添加到pom.xml中 如何使记录器在我的应用程序中可用?
import org.jboss.logging.Logger;
导入org.slf4j.LoggerFactory;
导入javax.enterprise.context.ApplicationScoped;
导入javax.enterprise.context.Dependent;
导入javax.enterprise.inject.Default;
导入javax.enterprise.inject.products;
导入javax.enterprise.inject.spi.InjectionPoint;
/**
*这将生成并配置记录器。
*
*@作者托马斯·赫尔佐格
*@自2018年8月6日起
*/
@适用范围
公共类记录器配置{
@产生
@违约
@依赖的
记录器createLogger(最终注入点ip){
if(ip.getBean()!=null){
返回Logger.getLogger(ip.getBean().getBeanClass());
}else if(ip.getMember()!=null){
返回Logger.getLogger(ip.getMember().getDeclaringClass());
}否则{
返回Logger.getLogger(“默认”);
}
}
}
我过去使用过Logstash或FluentD作为集中日志机制。不幸的是,我在这个项目中使用了graylog:(
<dependency>
<groupId>biz.paluch.logging</groupId>
<artifactId>logstash-gelf</artifactId>
<version>1.12.0</version>
<scope>provided</scope>
</dependency>
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.3" name="biz.paluch.logging">
<resources>
<artifact name="biz.paluch.logging:logstash-gelf:1.11.2" />
<artifact name="redis.clients:jedis:2.9.0" />
<artifact name="org.apache.commons:commons-pool2:2.4.3" />
</resources>
<dependencies>
<module name="org.apache.log4j" />
<module name="org.slf4j" />
<module name="javax.api" />
<module name="org.jboss.logmanager" />
</dependencies>
</module>
swarm:
jaeger:
logging:
file-handlers:
custom-handlers:
GELF-HTTP:
named-formatter: MY_LOG_PATTERN
attribute-class: biz.paluch.logging.gelf.wildfly.WildFlyGelfLogHandler
module: biz.paluch.logging
properties:
host: "http://graylog"
extractStackTrace: true
includeFullMdc: true
maximumMessageSize: 1048576
root-logger:
level: WARN
handlers:
- CONSOLE
- GELF-HTTP
import org.jboss.logging.Logger;
import org.slf4j.LoggerFactory;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Default;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
/**
* This produces and configures the logger.
*
* @author Thomas Herzog <herzog.thomas81@gmail.com>
* @since 06/08/18
*/
@ApplicationScoped
public class LoggerConfiguration {
@Produces
@Default
@Dependent
Logger createLogger(final InjectionPoint ip) {
if (ip.getBean() != null) {
return Logger.getLogger(ip.getBean().getBeanClass());
} else if (ip.getMember() != null) {
return Logger.getLogger(ip.getMember().getDeclaringClass());
} else {
return Logger.getLogger("default");
}
}
}