要在Apache NiFi中集成日志,您可以使用LogAttribute处理器将日志消息添加到流文件的属性中,然后使用PutFile或PutHDFS处理器将日志写入文件系统。
以下是一个示例流程:
以下是一个示例的NiFi流程模板,展示了上述解决方案的配置:
Apache NiFi Log Integration
org.apache.nifi
Log Integration
1a6a9c8d-016f-1000-ffff-ffffbe2759e4
284
84
GetFile
nifi-standard-nar
org.apache.nifi
1.13.2
Get Log File
true
success
Succeeds when a file is successfully retrieved
File Filter
.*\.log
Input Directory
/path/to/logs
Keep Source File
true
Recursive
true
1a6a9c8d-016f-1001-ffff-ffffbe2759e4
752
84
LogAttribute
nifi-standard-nar
org.apache.nifi
1.13.2
Add Log Message to Attributes
true
success
Succeeds when log message is added to attributes
Log Message
${log.message}
1a6a9c8d-016f-1002-ffff-ffffbe2759e4
1184
88
PutFile
nifi-standard-nar
org.apache.nifi
1.13.2
Write Log to File
true
success
Succeeds when log is successfully written to file
Directory
/path/to/output
Conflict Resolution Strategy
fail
File Name
${filename}.log
Use Compression
false
下一篇:Apache NiFi进程间通信