我们有办法将mule cloudhub日志提供给logstash吗?
我可以像在此链接中一样配置代理
https://docs.mulesoft.com/cloudhub/sending-data-from-arm-to-external-monitoring-software
但是我无法配置logstash。
答案 0 :(得分:1)
如果cloudhub允许连接到外部服务器,则可以使用log4j socket appender。您可以配置logstash以侦听tcp以获取日志,您可以参考此https://www.elastic.co/guide/en/logstash/current/plugins-inputs-tcp.html。 以下是logstash(https://gist.github.com/jgoodall/6323951)的tcp输入示例,请确保为mule设置正确的格式,因为多行数据存在问题。 同时配置您的应用程序,对于旧版本的mule,您可以添加log4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd-MM-yyyy HH:mm:ss} %-5p [%t] [%c] - %m%n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="ERROR" />
<param name="LevelMax" value="FATAL" />
<param name="AcceptOnMatch" value="true" />
</filter>
</appender>
<appender name="socket" class="org.apache.log4j.net.SocketAppender">
<param name="Threshold" value="INFO" />
<param name="application" value="AppName" />
<param name="Port" value="4560" />
<param name="RemoteHost" value="remotehost.com" />
<param name="ReconnectionDelay" value="60000" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd-MM-yyyy HH:mm:ss} %-5p [%t] [%c] - %m%n" />
</layout>
</appender>
<appender name="asyncConsole" class="org.apache.log4j.AsyncAppender">
<param name="BufferSize" value="200"/>
<appender-ref ref="console"/>
</appender>
<appender name="asyncFile" class="org.apache.log4j.AsyncAppender">
<param name="BufferSize" value="200"/>
<appender-ref ref="file"/>
</appender>
<appender name="asyncSocket" class="org.apache.log4j.AsyncAppender">
<param name="BufferSize" value="200"/>
<appender-ref ref="socket"/>
</appender>
<logger name="Tracking" additivity="false">
<level value="warn" />
<appender-ref ref="asyncConsole" />
<appender-ref ref="asyncFile" />
<appender-ref ref="asyncSocket" />
</logger>
<logger name="com.mulesoft.module.datamapper" additivity="false">
<level value="warn" />
<appender-ref ref="asyncConsole" />
<appender-ref ref="asyncFile" />
<appender-ref ref="asyncSocket" />
</logger>
<logger name="org.mule.api.processor.LoggerMessageProcessor" additivity="false">
<level value="info" />
<appender-ref ref="asyncConsole" />
<appender-ref ref="asyncFile" />
<appender-ref ref="asyncSocket" />
</logger>
<root>
<priority value="info" />
<appender-ref ref="asyncConsole" />
<appender-ref ref="asyncFile" />
<appender-ref ref="asyncSocket" />
</root>
注意socket appender,你可以从那里配置logstash实例的主机和端口。对于较新版本的mule,有一个log4j2.xml,socket appender的配置类似。