jenkins maven项目控制台打印jar包启动日志,优化后方法

    确认项目启动情况最准确的方法,那就是看启动日志了;当用jenkins的maven项目启动java时,如何在项目启动后打印日志咧。

 

以前

  tail -f 200 log/*.log

  简单粗暴,打印后面200行,大家想想就知道这个方法是挺low的。

优化后

  sleep 1 #启动后,暂停1s方法收集打印更完整日志

  tail -n 800 log/*.log |grep -A 200 "The following profiles are active" 

       思路:进程启动等1s日志打印;

                tail后面800行(为了找到spring boot启动关键字,可调整);

                grep关键字“The following profiles are active”,这个是springboot启动的关键字;

                grep -A 200  是打印输出关键字后面200行。

posted @ 2020-04-23 15:12  嘿十三  阅读(3680)  评论(1)    收藏  举报