简体   繁体   English

在WSO2 ESB中记录顺序调用

[英]Logging sequence calls in WSO2 ESB

I've got a sequence template that does many different calls. 我有一个执行许多不同调用的序列模板。 Every call logs some parameters / infos. 每个调用都会记录一些参数/信息。

What I'm trying to achieve is to have some sort of identifier (let's say a unique id) to be passed to all the calls during a sequence execution. 我想要实现的是在序列执行期间将某种标识符(例如,唯一的ID)传递给所有调用。

The goal is to trace all the steps of a single execution from the logs, mainly for debugging purposes. 目的是从日志中跟踪单个执行的所有步骤,主要是为了调试。

Actually the only idea that came to my mind is to do that programmaticaly, as to say, create a uid at the beginning of the sequence, passing it around, and save it in the log calls. 实际上,我想到的唯一想法就是以编程方式进行操作,也就是说,在序列的开头创建一个uid,将其传递给它,然后将其保存在log调用中。 I also tried to mess around with the LogMediator, to make it extract the infos automatically from the external params, but failed (maybe I'm doing it wrong). 我还尝试弄乱LogMediator,以使其从外部参数中自动提取信息,但是失败了(也许我做错了)。

Is there any smarter method to do that? 有没有更聪明的方法可以做到这一点?

Your requirement can be achieved in various ways. 您的要求可以通过多种方式实现。 I'm mentioning one of those possibilities. 我要提到的是其中一种可能性。

Since this is an additional method you are going to use for debugging purposes, I think it is better to have a separate log file for this purpose. 由于这是您将用于调试的另一种方法,因此我认为最好为此使用一个单独的日志文件。 So first create a new file appender something similar to one given below. 因此,首先创建一个新的文件追加器,类似于下面给出的。

log4j.logger.com.test.CustomDebug=DEBUG, CUSTOM_DEBUG
log4j.additivity.com.test.CustomDebug=false

log4j.appender.CUSTOM_DEBUG = org.apache.log4j.DailyRollingFileAppender
log4j.appender.CUSTOM_DEBUG.File = /home/upul/log/moredebug.log
log4j.appender.CUSTOM_DEBUG.layout = org.apache.log4j.PatternLayout
log4j.appender.CUSTOM_DEBUG.Append = true

Next, create a custom mediator called CustomDebug . 接下来,创建一个名为CustomDebug的自定义介体。 Inside mediate() method read parameters from the MessageContext . mediate()方法内部,从MessageContext读取参数。 Next, do some processing (if you have any) and finally, write your log message using log.debug() . 接下来,进行一些处理(如果有的话),最后,使用log.debug()编写日志消息。 This debug message will be written you the new file you created above (in this case it will be /home/upul/log/moredebug.log ). 该调试消息将被写入您在上面创建的新文件中(本例中为/home/upul/log/moredebug.log )。

public class CustomDebug extends AbstractMediator {

    private static final Log log = LogFactory.getLog(CustomDebug.class);

    public boolean mediate(MessageContext mc) {

    }
}

Next, insert CustomDebug class mediator to appropriate places of your sequence template and pass uid as an argument. 接下来,将CustomDebug类介体插入序列模板的适当位置,并将uid作为参数传递。

As I mentioned previously, this is one of the methods you can use for creating your custom logging. 如前所述,这是可用于创建自定义日志记录的方法之一。 You might need to look at other possibilities as well. 您可能还需要考虑其他可能性。

If you need further help regarding this issue please let me know. 如果您需要有关此问题的进一步帮助,请告诉我。

Thanks, 谢谢,

Upul Upul

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

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