mule使用流定制记录器

mule使用流定制记录器,mule,Mule,我有四个流,每个流都有http端点: <flow1 > <http:myhosts:port path="test1"> </flow1> <flow2> <http:myhosts:port path="test2"> </flow2> <flow3> <http:myhosts:port path="test3"> </flow3> <flow4> <http:myh

我有四个流,每个流都有http端点:

<flow1 >
<http:myhosts:port path="test1">
</flow1>
<flow2>
<http:myhosts:port path="test2">
</flow2>
<flow3>
<http:myhosts:port path="test3">
</flow3>
<flow4>
<http:myhosts:port path="test4">
</flow1>
它使用单个文件名打印tmp目录中的记录器

我需要做的是,对于每个流或url,mule都必须创建日志文件test1-12:20:00(当前时间).log 所以,如果我运行4个流,那么我需要创建4个日志文件,如下所示

test1-12:20:00(present-time).log
test1-13:20:00(present-time).log
test1-14:20:00(present-time).log
test1-15:20:00(present-time).log

我怎么做这个?在Mule配置中可以做到这一点吗?

如果不做大量工作,仅使用log4j是无法做到这一点的。但是,您可以使用
#[flow.name]

预先编写日志消息,我认为您可以使用类别来完成此操作

首先,在log4j中创建四个独立的appender。对于Mule 3.5,您可以继续使用properties配置,但请记住,由于迁移到log4j2,您将不得不转到Mule 3.6中的XML配置

log4j.appender.thing1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.thing1.File=/var/log/integration/Thing1/mylogs.log
# etc...
log4j.appender.thing2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.thing2.File=/var/log/integration/Thing2/mylogs.log
# etc...
然后,为特定类别定义记录器,如下所示:

log4j.logger.com.mycompany.Thing1=DEBUG,thing1
log4j.logger.com.mycompany.Thing2=DEBUG,thing2
# etc...
最后,在流中添加使用适当类别的记录器:

<flow name="Thing1">
    <!-- your flow logic goes here -->
    <logger category="com.mycompany.Thing1" message="Something happened" level="INFO" />
    <!-- more flow logic goes here -->
</flow>

<flow name="Thing2">
    <!-- your other flow logic goes here -->
    <logger category="com.mycompany.Thing2" message="Something happened in flow 2" level="INFO" />
    <!-- more flow logic goes here -->
</flow>


请注意,当您迁移到3.6并开始使用log4j2时,您将能够利用更灵活的功能,并且可以更好地控制何时滚动以及如何生成文件名。

我认为在Mule中不可能做到这一点。
<flow name="Thing1">
    <!-- your flow logic goes here -->
    <logger category="com.mycompany.Thing1" message="Something happened" level="INFO" />
    <!-- more flow logic goes here -->
</flow>

<flow name="Thing2">
    <!-- your other flow logic goes here -->
    <logger category="com.mycompany.Thing2" message="Something happened in flow 2" level="INFO" />
    <!-- more flow logic goes here -->
</flow>