javalinuxspring-bootlogginginit.d

Disable system logs for Spring Boot app running as Linux init.d service


I have a Spring boot application running on docker container as an init.d service. I followed the Spring Boot Unix/Linux Services guide to set it up.

Since the application is being started as a daemon service, the operating system creates log file under the /var/log/ directory and records the application logs in there. The problem is that since the application has lots of logging, the file increases in size rapidly. Moreover, I have a logback configured to manage application logs, thus, I do not need the default system logging.

I tried customizing the startup script but I only managed to change the default values (LOG_FILENAME and LOG_FOLDER), not remove them.

So my question is: Is there a way I can disable system logs for specific init.d service? If yes, how?


Solution

  • One solution is to create .conf file having the same name as the application .jar file and put them into the same directory. For example:

    /home/
          application.jar
          application.conf
    

    Now that you have the .conf file next to the .jar, open it and write

    LOG_FOLDER=/dev
    LOG_FILENAME=null
    

    As described here, /dev/null will discard everything written there but will return success.

    The drawback of this approach is that changing the .jar file name or directory will require changes in the .conf file respectively.