Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在日志中打印Spring计划信息_Spring - Fatal编程技术网

在日志中打印Spring计划信息

在日志中打印Spring计划信息,spring,Spring,我正在使用Spring@Schedule注释来安排作业。有没有办法打印@Schdeule何时开始作业?我已经启用了跟踪级别日志记录,但是没有在与计划相关的日志中打印任何内容。基本上我是在考虑我的日程安排开始的时间- @Service public class Listener{ @Log private Logger logger; @Scheduled(cron = "0 12 16 * * *") public void closing() throw

我正在使用Spring@Schedule注释来安排作业。有没有办法打印@Schdeule何时开始作业?我已经启用了跟踪级别日志记录,但是没有在与计划相关的日志中打印任何内容。基本上我是在考虑我的日程安排开始的时间-

@Service
public class Listener{

    @Log
    private Logger logger;



    @Scheduled(cron = "0 12 16 * * *")
    public void closing() throws Exception {
        //do work here

    }
}

谢谢

实现这一点的简单方法是在方法的开头添加一个日志。该日志还将写入日期:

@服务
公共类侦听器{
@日志
私人记录器;
@已计划(cron=“0 12 16***”)
public void closing()引发异常{
logger.info(“方法的开始”);
//你在这里工作吗
}
}

它将在计划运行时打印。我希望在计划运行前打印。当detect@Schedule时,spring似乎没有在日志中放入任何内容