将日志添加到 wso2 以跟踪在自定义 java 代码中实现的日志
Adding logs to wso2 to track logs implemented in custom java code
下面我有一个自定义 API 管理器调解器的代码片段,我想修改此代码以供我们使用。当我在我们的 wso2 环境中 运行 时,我无法从代码中获取日志。能够输出这些日志的过程是什么。这将是我添加到 APIM 的 repository/components/lib/ 目录中的一个 jar 文件。 jar 文件名为 com.domain.wso2.apim.extensions。我需要能够看到正在传递的内容以及代码的哪些部分正在被测试
public class IdentifiersLookup extends AbstractMediator implements ManagedLifecycle {
private static Log log = LogFactory.getLog(IdentifiersLookup.class);
private String propertyPrefix = "";
private String netIdPropertyToUse = "";
private DataSource ds = null;
private String DsName = null;
public void init(SynapseEnvironment synapseEnvironment) {
if (log.isInfoEnabled()) {
log.info("Initializing IdentifiersLookup Mediator");
}
if (log.isDebugEnabled())
log.debug("IdentifiersLookup: looking up datasource" + DsName);
try {
this.ds = (DataSource) new InitialContext().lookup(DsName);
} catch (NamingException e) {
e.printStackTrace();
}
if (log.isDebugEnabled())
log.debug("IdentifiersLookup: acquired datasource");
}
将以下行添加到 log4j.properties 文件所在的 wso2am-2.0.0/repository/conf/ 文件夹并重新启动服务器。
log4j.logger.com.domain.wso2.apim.extensions=INFO
下面我有一个自定义 API 管理器调解器的代码片段,我想修改此代码以供我们使用。当我在我们的 wso2 环境中 运行 时,我无法从代码中获取日志。能够输出这些日志的过程是什么。这将是我添加到 APIM 的 repository/components/lib/ 目录中的一个 jar 文件。 jar 文件名为 com.domain.wso2.apim.extensions。我需要能够看到正在传递的内容以及代码的哪些部分正在被测试
public class IdentifiersLookup extends AbstractMediator implements ManagedLifecycle {
private static Log log = LogFactory.getLog(IdentifiersLookup.class);
private String propertyPrefix = "";
private String netIdPropertyToUse = "";
private DataSource ds = null;
private String DsName = null;
public void init(SynapseEnvironment synapseEnvironment) {
if (log.isInfoEnabled()) {
log.info("Initializing IdentifiersLookup Mediator");
}
if (log.isDebugEnabled())
log.debug("IdentifiersLookup: looking up datasource" + DsName);
try {
this.ds = (DataSource) new InitialContext().lookup(DsName);
} catch (NamingException e) {
e.printStackTrace();
}
if (log.isDebugEnabled())
log.debug("IdentifiersLookup: acquired datasource");
}
将以下行添加到 log4j.properties 文件所在的 wso2am-2.0.0/repository/conf/ 文件夹并重新启动服务器。
log4j.logger.com.domain.wso2.apim.extensions=INFO