简体   繁体   English

使用Log4J进行工作流日志记录

[英]Workflow logging using Log4J

I have defined two loggers MainLogger, SecondLogger which logs the debug statements to two separate files Main.log and Second.log respectively and defined the categories like 我定义了两个记录器MainLogger,SecondLogger,它们分别将调试语句记录到两个单独的文件Main.log和Second.log中,并定义了类似的类别

<appender name="MainLogger" class="org.apache.log4j.FileAppender">
        <param name="File" value="Main.log" />
</appender>

<appender name="SecondLogger" class="org.apache.log4j.FileAppender">
        <param name="File" value="Second.log" />
</appender>

<category name="Fully.Qualified.ClassA" additivity="false">
        <priority value="INFO" />
        <appender-ref ref="MainLogger" />
    </category>

<category name="Fully.Qualified.ClassB" additivity="false">
        <priority value="INFO" />
        <appender-ref ref="SecondLogger" />
</category>

The issue is, both the work flows share the ClassA and ClassB. 问题是,两个工作流程共享ClassA和ClassB。 So the Main.log is filled with high traffic work flow which is difficult to manage. 因此Main.log充满了难以管理的高流量工作流程。

How do I limit the work flows to go to respective log files only? 如何限制工作流程仅转到相应的日志文件?

Is there any solution to route the current thread log statements to one particular log file only? 有什么解决方案可以将当前线程日志语句仅路由到一个特定的日志文件?

Your problem seems like it might be solvable using the technique this question is using. 您的问题似乎可以使用此问题使用的技术来解决。

Basically, it looks like he's programatically setting up new appenders for every threaded instance of the class. 基本上,看起来他以编程方式为该类的每个线程实例设置了新的追加程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM