java 启动jar包 借助 cronolog来分隔日志

第一种:安装cronolog

Mac

brew install cronolog

Linux

  1. Download (the latest version )
    wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
  2. Unzip
    tar zxvf cronolog-1.6.2.tar.gz
  3. Enter the directory where the cronolog installation file is located
    cd cronolog-1.6.2
  4. Run and install
    ./configure
    make
    make install
  5. Check the directory where cronolog is installed (verify whether the installation is successful)
    which cronolog
    Under normal circumstances, it is displayed as: /usr/local/sbin/cronolog

参考:

  1. https://blog.katastros.com/a?ID=00850-24925358-9bb7-462e-bfce-628b2eea1566
  2. https://blog.csdn.net/wodiaonihai/article/details/122407459

启动 jar 包

nohup java -jar common-api.jar | /usr/local/cronolog/sbin/cronolog logs/console-%Y-%m-%d.out &

nohup java -jar bop-data-1.0-SNAPSHOT.jar | /usr/local/cronolog/sbin/cronolog /root/logs/%Y-%m-%d-bop-data.log &

第二种:使用apache自带日志分割模块rotatelogs,分割日志

安装 httpd,因为rotatelogs在apache中

yum install httpd

启动

service httpd start

查看

which rotatelogs

启动

nohup java -jar bop-data-1.0-SNAPSHOT.jar | /usr/sbin/rotatelogs /root/logs/%Y%m%d-bop-data.log 86400 480 &

结果

image

参考:https://www.cnblogs.com/naledao/p/3230623.html

posted @   西门长海  阅读(690)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示