Mule ESB Log4j2支持
Mule ESB是否支持log4j2?我试图在我的esb应用程序中添加log4j2.xml,但即使在添加了log4j2.xml之后,我的mule esb应用程序仍默认使用自己的log4j1.2实现。我希望我的esb应用程序读取我的log4j2.xml文件,并获取/使用我在log4j2.xml中指定的参数,如果存在log4j2.xml文件,则它不应读取自己的log4j 1.2实现日志属性文件Mule ESB Log4j2支持,mule,log4j2,Mule,Log4j2,Mule ESB是否支持log4j2?我试图在我的esb应用程序中添加log4j2.xml,但即使在添加了log4j2.xml之后,我的mule esb应用程序仍默认使用自己的log4j1.2实现。我希望我的esb应用程序读取我的log4j2.xml文件,并获取/使用我在log4j2.xml中指定的参数,如果存在log4j2.xml文件,则它不应读取自己的log4j 1.2实现日志属性文件 我在使用mule esb应用程序实现log4j2(.xml)时遇到问题。非常感谢您的帮助。Log4j2有一
我在使用mule esb应用程序实现log4j2(.xml)时遇到问题。非常感谢您的帮助。Log4j2有一个适配器,允许根据log4j-1.2api编码的应用程序使用Log4j2实现。(另请参见。) 实现这一目标的步骤:
- 从类路径中删除log4j-1.2.x.jar
- 将log4j-1.2-api-2.0.jar添加到类路径李>
- 确保log4j-api-2.0.jar和log4j-core-2.0.jar在类路径中
现在,log4j-1.2api和log4j2api都将委托给log4j2实现。示例配置是。最新版本的mule esb支持log4j2。希望该版本可能是紧密耦合的,这可能是它无法工作的原因。Log4j2从Mule-3.6.0开始就受到隐式支持。有关更多信息,请访问此链接Mule esb支持log4j。 检查是否已导入slf4j库
您需要创建/重命名log4j2 test.xml这些是我的log4j2.xml和pom.xml文件,我使用的是mule v7.1。 我希望有帮助 log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="debug">
<Properties>
<Property name="log-path">/my_path/my_logs/my_app</Property>
<Property name="app-id">my_app</Property>
</Properties>
<Appenders>
<RollingFile name="file-log" fileName="${log-path}/${app-id}.log"
filePattern="${log-path}/${app-id}-%d{yyyy-MM-dd}.log">
<PatternLayout>
<pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1"
modulate="true" />
</Policies>
</RollingFile>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout
pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Logger name="org.apache.logging.log4j" level="warn" additivity="false">
<appender-ref ref="file-log" />
<appender-ref ref="console" />
</Logger>
<Root level="info" additivity="false">
<appender-ref ref="file-log" />
<appender-ref ref="console" />
</Root>`enter code here`
</Loggers>
</Configuration>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0</version>
</dependency>
/我的路径/我的日志/我的应用
我的应用程序
[%-5level]%d{yyyy-MM-dd HH:MM:ss.SSS}[%t]%c{1}-%msg%n
`在这里输入代码`
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="debug">
<Properties>
<Property name="log-path">/my_path/my_logs/my_app</Property>
<Property name="app-id">my_app</Property>
</Properties>
<Appenders>
<RollingFile name="file-log" fileName="${log-path}/${app-id}.log"
filePattern="${log-path}/${app-id}-%d{yyyy-MM-dd}.log">
<PatternLayout>
<pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n
</pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1"
modulate="true" />
</Policies>
</RollingFile>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout
pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
</Console>
</Appenders>
<Loggers>
<Logger name="org.apache.logging.log4j" level="warn" additivity="false">
<appender-ref ref="file-log" />
<appender-ref ref="console" />
</Logger>
<Root level="info" additivity="false">
<appender-ref ref="file-log" />
<appender-ref ref="console" />
</Root>`enter code here`
</Loggers>
</Configuration>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0</version>
</dependency>
org.apache.logging.log4j
log4japi
2
org.apache.logging.log4j
log4j型芯
2
任何使用mule esb的log4j2.xml示例对我来说都是非常好的开始。谢谢。请浏览MuleSoft的博客。员工:谢谢。我会试试这个。:)不是真的。即使从类路径中删除log4j-1.2.x.jar,Mule也会自己加载log4j-1.2,并且不会读取log4j2.xml。Mule仍然只读取log4j.properties。slf4j日志语句没有按照log4j2.xml中的定义进行重定向,mule中的slf4j日志语句只遵循log4j.properties文件中的定义。如果从类路径中删除log4j-1.2.x.jar,mule将自动将其放回,我认为问题在于mule。也许这个行为可以通过mule配置来控制,否则你需要要求mule开发人员改变这个……我读过一些关于mule中log4j的紧密耦合的文章。请记住这一点。你可能会在这里找到一些答案()似乎已经让它起作用了,所以它应该是可能的。。。(不确定他是否使用相同的Mule版本。)