Linux deployment springboot project log color print script

Ah, the deployment of the project, found a log looks awful, like a good idea in color, ready to write a script,

 

 after modification

 

 

Ah, write a script, the log file name as an argument passed into it. "

Then look at the log script when run directly on the OK

Create a sh script, scripted content, the log file name as a parameter inside.

vim ./tail_style.sh

#! /bin/bash
tail  -f  $1 | perl -pe's/(INFO)|(DEBUG)|(WARN)|(ERROR)|(^[0-9-:.\s]{10,23})|((?<=[OGNR]\s)[0-9]{1,5})|((?<=\[.{15}\]\s).{1,40}(?=\s(:\s)|\s))/\e[1;32m$1\e[0m\e[1;36m$2\e[0m\e[1;33m$3\e[0m\e[1;31m$4\e[0m\e[1;34m$5\e[0m\e[1;35m$6\e[0m\e[1;36m$7\e[0m/g'

 

 

Then you need to give permission to the script:

chmod 777 tail_style.sh

 

 Then you can run it, nohup.out for the log file

./tail_style.sh nohup.out 

Script parameters ....  

 

Guess you like

Origin www.cnblogs.com/liruilong/p/12387585.html