第一种:安装cronolog
Mac
brew install cronolog
Linux
wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
tar zxvf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure
make
make install
which cronolog
Under normal circumstances, it is displayed as: /usr/local/sbin/cronolog
参考:
启动 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 &
结果
参考:www.cnblogs.com/naledao/p/3…