首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JSR352 - JBERET -如何检查java批处理程序作业日志?

JSR352 - JBERET -如何检查java批处理程序作业日志?
EN

Stack Overflow用户
提问于 2017-09-28 01:59:55
回答 1查看 900关注 0票数 0

我试图使用JBERET实现在java模式下运行JSR352 Java批处理程序。我可以看到我的main()方法正在被执行。在这个main()方法中,我获得了作业操作符的句柄,并启动了作业。

代码语言:javascript
复制
public static void main(String[] args) {

    LoggingConfig logConfiguration = new LoggingConfig();

    logger.info("Begining Batch with JBeret approach");

    JobOperator jo = BatchRuntime.getJobOperator();
    long id = jo.start("PilotJob", null);

    logger.info("End of Batch");

}

但是,我没有看到我的阅读器、处理器、作者或侦听器中有任何日志语句被打印出来。

我从我的项目src/main/resources/META文件夹中定义并加载了一个logging.properties。main()方法中的log语句是根据它打印的,但是,我的阅读器/作者/处理器和侦听器中的日志语句根本没有打印。

代码语言:javascript
复制
public class LoggingConfig {
    public LoggingConfig() {
        try {
            // Load a properties file from class path that way can't be achieved
            // with java.util.logging.config.file

              final LogManager logManager = LogManager.getLogManager(); 
              try (final InputStream is = getClass().getResourceAsStream("/META-INF/logging.properties")) 
              {
                  logManager.readConfiguration(is);
              }

        } catch (Exception e) {
            System.out.println("Error while reading Log configuration file");
            e.printStackTrace();
        }
    }
}

为什么我的日志语句(java日志库)不在我的java批处理程序中打印?

下面是main()方法中的日志。我可以清楚地看到作业已经启动,但不确定为什么批处理程序的日志语句没有被打印出来。

代码语言:javascript
复制
    INFO: App Begining Batch with JBeret approach - v1.0
    INFO: org.jboss.weld.Version WELD-000900: 2.2.15 (Final)
    INFO: org.jboss.weld.Bootstrap WELD-ENV-000014: Falling back to Java Reflection for bean-discovery-mode="annotated" discovery. Add org.jboss:jandex to the classpath to speed-up startup.
    INFO: org.jboss.weld.Bootstrap WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
    WARN: org.jboss.weld.Interceptor WELD-001700: Interceptor annotation class javax.ejb.PostActivate not found, interception based on it is not enabled
    WARN: org.jboss.weld.Interceptor WELD-001700: Interceptor annotation class javax.ejb.PrePassivate not found, interception based on it is not enabled
    DEBUG: org.jboss.weld.Bootstrap WELD-000100: Weld initialized. Validating beans
    DEBUG: org.jboss.weld.Reflection WELD-000620: interface javax.enterprise.inject.Intercepted is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make the application unportable.
    DEBUG: org.jboss.weld.Reflection WELD-000620: interface javax.enterprise.inject.Decorated is not declared @Target(METHOD, FIELD, PARAMETER, TYPE). Weld will use this annotation, however this may make the application unportable.        
    FINE: javax.batch.runtime.BatchRuntime Loaded BatchContainerServiceProvider with className = org.jberet.operations.JobOperatorImpl
    TRACE: org.jberet JBERET000022: resume is not implemented for local transactions
    DEBUG: org.jberet JBERET000017: Persisted org.jberet.runtime.JobInstanceImpl@6 with id 6
    DEBUG: org.jberet JBERET000017: Persisted org.jberet.runtime.JobExecutionImpl@6 with id 6
    INFO: App End of Batch

下面是一个监听器代码,它具有Sysout和Log语句。它们都没有被打印在我的Eclipse控制台中。

代码语言:javascript
复制
import java.util.logging.Logger;

import javax.batch.api.listener.AbstractJobListener;

public class PilotLibJobListener extends AbstractJobListener {

    private final static Logger logger = Logger.getLogger("PilotLibJobListener");   

    public void beforeJob() {
        BatchListenerRecorder.batchListenersCountDownLatch.countDown();
        System.out.println("Before Job");
        logger.info("MyJobListener.beforeJob");
    }

    @Override
    public void afterJob() {
        BatchListenerRecorder.batchListenersCountDownLatch.countDown();
        logger.info("MyJobListener.afterJob");
    }

}
EN

回答 1

Stack Overflow用户

发布于 2017-09-28 02:39:53

要查询作业执行状态,只需在JobOperator上调用适当的API,例如public JobExecution getJobExecution(long executionId)。返回的JobExecution对象包含最新数据。

对于作业存储库,如果jdbc作业存储库对应用程序来说太重,则可以选择内存中的作业存储库。但是使用默认的H2数据库,您可以配置为具有嵌入式或基于文件的H2数据库,而不是客户机-服务器模式,以限制资源消耗。

对于日志记录问题,您可以创建一个JIRA问题github问题,并附加一个可复制的测试应用程序吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46459807

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档