In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use SpringBoot_jar to start and configure log files, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Start and configure log file preface in SpringBoot_jar mode
To start normally, the default startup file configured in application.properties will be selected to start. The following situation cannot start the project according to the actual situation.
Java jar admin-1.0-SNAPSHOT.jar
1. Test environment and production environment startup
Mainly observe the name of the configuration file in priperties
Test environment: java-jar my-spring-boot.jar-- spring.profiles.active=test
Production environment: java-jar my-spring-boot.jar-spring.profiles.active=prod
2. Launch and configure log log 2.1with shell, launch test library #! / bin/bash echo starting java-jar admin-1.0-SNAPSHOT.jar-- spring.profiles.active=test > log.file 2 > log.error & 2.2, formal library launch #! / bin/bash echo starting java-jar admin-1.0-SNAPSHOT.jar-- spring.profiles.active=prod > log.file 2 > & 1 & 2.3, Stop the running project #! / bin/bash PID=$ (ps-ef | grep admin-1.0-SNAPSHOT.jar | grep-v grep | awk'{print $2}') if [- z "$PID"] then echo Application is already stoppedelse echo kill $PID kill $PIDfi2.4, restart the project #! / bin/bashecho stop applicationsource stop.shecho start applicationsource start.shJar package start and output the log in the background
Everyone deploys the project in the server, and the jar package needs to be started in the background, so it will not end the process because of your Ctrl+c, or if you close the terminal.
Format:
Nohup java-jar JarName > JarName.log &
Nohup... & # can make the process start in the background, and it is also suitable for many kinds of programs to start
When the jar package starts in the background, you need to put your startup command into it, or you can add other parameters when you start the jar package again.
For example, nohup java-Duser.timezone=GMT+8-Dfile.encoding=utf-8-Xms1024m-Xmx1024m-Djava.io.tmpdir=$DATA_DIR/tmp-jar $DATA_DIR "/" $JAR & these are all the contents of the article "how to start and configure log files using SpringBoot_jar". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.