istio默认会进行日志的记录,可是仅仅记录到服务、以及服务之间调用的信息,不记录业务日志。java
如:python
因此须要添加业务日志记录。git
1.引入依赖github
<dependency>
<groupId>org.fluentd</groupId>
<artifactId>fluent-logger</artifactId>
<version>
0.3
.
3
</version>
</dependency>
|
2.代码中引入相关类,并链接fluent服务ui
import org.fluentd.logger.FluentLogger;
1) 本地调用远程fluent服务url
private static FluentLogger log = FluentLogger.getLogger("service-a.ServiceController","192.168.181.99",30224);spa
2)istio线上调用fluent服务
private static FluentLogger log = FluentLogger.getLogger("service-a.ServiceController","fluentd-es.logging",24224);
详解:.net
service-a.ServiceController为记录日志tag日志
192.168.181.99 为远程fluent服务code
30224 为远程fluent服务的端口
建议:
tag为 当前服务名+类名
远程fluent服务不指定,默认为本地fluent服务
3.记录日志
详解:
log.log方法参数:tag建议为方法名称,key为(info,error,warn)中的一个,value为记录的信息。
4.fluent ui 展示状况
详解:
由于方法info 调用了notify方法,并且notify方法报错,因此fluent收到两条记录。
5.事例项目(jeager-fluent分支)
https://github.com/jiuchongxiao/istio-python-hello-jaeger.git