• linux后台启动springboot并指定日志文件名称


      如果用nohup启动jar包的话,默认的日志文件就是nohup.out,那么如果启动多个jar包的话,看日志文件就麻烦了,因为他们都会写入到nohup.out文件中。

      所以我们来指定一下不同jar包的日志文件名:

    [prize@centos ~]$ mkdir log
    [prize@centos ~]$ nohup java -jar dianyixia-0.0.1-SNAPSHOT.jar > log/dianyixia.log &
    [1] 5861
    [prize@centos ~]$ nohup: ignoring input and redirecting stderr to stdout

      看一眼,日志确实写入到dianyixia.log文件中了:

    [prize@centos ~]$ cat log/dianyixia.log 
    
      .   ____          _            __ _ _
     /\ / ___'_ __ _ _(_)_ __  __ _    
    ( ( )\___ | '_ | '_| | '_ / _` |    
     \/  ___)| |_)| | | | | || (_| |  ) ) ) )
      '  |____| .__|_| |_|_| |_\__, | / / / /
     =========|_|==============|___/=/_/_/_/
     :: Spring Boot ::        (v2.2.2.RELEASE)
    
    2019-12-23 11:37:19.899  INFO 5861 --- [           main] c.w.o.dianyixia.DianyixiaApplication     : Starting DianyixiaApplication v0.0.1-SNAPSHOT on VM_0_14_centos with PID 5861 (/home/prize/dianyixia-0.0.1-SNAPSHOT.jar started by prize in /home/prize)
    2019-12-23 11:37:19.905  INFO 5861 --- [           main] c.w.o.dianyixia.DianyixiaApplication     : No active profile set, falling back to default profiles: default
    2019-12-23 11:37:22.500  INFO 5861 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9998 (http)
    2019-12-23 11:37:22.531  INFO 5861 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
    2019-12-23 11:37:22.531  INFO 5861 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.29]
    2019-12-23 11:37:22.711  INFO 5861 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
    2019-12-23 11:37:22.711  INFO 5861 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2672 ms
    2019-12-23 11:37:24.099  INFO 5861 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
    2019-12-23 11:37:24.552  INFO 5861 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9998 (http) with context path ''
    2019-12-23 11:37:24.555  INFO 5861 --- [           main] c.w.o.dianyixia.DianyixiaApplication     : Started DianyixiaApplication in 5.653 seconds (JVM running for 6.653)

      如法炮制,再来一个:

    [prize@centos ~]$ nohup java -jar prize-0.0.1-SNAPSHOT.jar > log/prize.log &
    [2] 6306
    [prize@centos ~]$ nohup: ignoring input and redirecting stderr to stdout

      

      看看

    [prize@centos ~]$ tail -f log/prize.log 
            ...]
    2019-12-23 11:40:34.186  INFO 6306 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.10.Final}
    2019-12-23 11:40:34.192  INFO 6306 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
    2019-12-23 11:40:34.672  INFO 6306 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
    2019-12-23 11:40:35.340  INFO 6306 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
    2019-12-23 11:40:36.980  INFO 6306 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
    2019-12-23 11:40:38.777  INFO 6306 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
    2019-12-23 11:40:38.901  WARN 6306 --- [           main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
    2019-12-23 11:40:39.474  INFO 6306 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 9988 (http) with context path ''
    2019-12-23 11:40:39.480  INFO 6306 --- [           main] com.wlf.order.prize.PrizeApplication     : Started PrizeApplication in 12.758 seconds (JVM running for 13.763)
  • 相关阅读:
    Knime 使用 初探
    MySql可视化工具MySQL Workbench使用教程
    MySQL导入sql 文件的5大步骤
    Import MySQL Dumpfile, SQL Datafile Into My Database
    导入已有的vmdk文件,发现网络无法连通
    VirtualBox镜像复制载入
    对自己说的话
    linux遇见的问题
    vbox下安装 linux 64 bit出现“kernel requires an x86_64 cpu
    Servlet 3 HttpServletRequest HttpServletResponse 验证码图片 form表单
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/12082915.html
Copyright © 2020-2023  润新知