spring boot log file being overwritten on restart - spring-boot

I'm using https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html to start my spring-boot application on ubuntu 14.04 and it's working great except my log file gets overwritten whenever I restart the app. Probably it's something simple... but how can I configure that behaviour? I'm just using the default console logging to /var/log/app_name.log. If I pass in the logback "--logging.file=..." config to the init script, it logs both to the default as well as this file and this file doesn't get overwritten. Thanks!

Related

SpringBoot Config Server file separator issue

I have configued Spring Boot Config server (2.4.1 version) integrated with Git repository.
Config looks valid, there is no issue during loading files from git, however when i point to
localhoast:port/application/dev
i get
{"name":"application","profiles":["dev"],"label":null,"version":"7e67e69e075b05d9fa50e3255deef7585ed658c7","state":null,"propertySources":[]}
I turned on logging everything and I discovered, that config server downloaded file correctly and saved file somewhere in temp folder like:
(1) C:/Users/username/AppData/Local/Temp/config-repo-5493381163789847226/
however NativeEnironmentRepository is expecting that it will be in:
(2) C:\Users\username\AppData\Local\Temp\config-repo-5493381163789847226\
which is also valid windows path.
When I turn on debuggin I found out that
NativeEnvironmentRepository check path (1)
against pattern (2) and it fails. So in result
"propertySources":[]
is empty.
Is this a bug on SpringBoot config server? or should I setup/change something in configuration?
It looks like NativeEnvironmentRepository should use system File.separator...
I had same issue with spring boot 2.4.1 in windows platform. It is solved by spring 2.4.2.snapshot.
Spring 2.4.1 worked properly in linux ubuntu. I dont know what is the problem.

spring boot logging.file not getting created in openshift

I want to export the logs of a spring boot application into a file in order to preserve it in a persistent volume.
In application.properties i added logging.file=myapplication.log
When i build and run the docker image locally, the myapplication.log file gets created in the container. But when i push the image to the Openshift internal registry and do
`oc new-app --name=<app> <image-name>`
the container gets created and works fine but the log file does not exist. I also tried inserting -Dlogging.file=myapplication.log in the dockerfile which also works locally but not in openshift.
What i am doing wrong! I am going insane!

How can I fix: "start-stop-daemon: warning: this system is not able to track process names" when starting springboot as a systemd service?

When I start my spring boot app as a systemd service I receive this error:
start-stop-daemon: warning: this system is not able to track process names longer than 15 characters, please use --exec instead of --name.
Spring boot seems to build the process name from the jar name and the directory the jar is contained in. Is there any way to fix this aside from renaming the jar, and the directory it's contained in, to be shorter than 15 characters?
If I try to edit spring boots startup script to use --exec instead of --name then I get another error:
'start-stop-daemon: unable to stat /opt/program/programname_optprogramname (No such file or directory)
It appears that this issue is fixed in Spring boot 2.0.2. So if you run into this issue upgrading might fix it (not to imply that upgrading is always a simple effort)

disable spring boot default logging to /var/logs/app.log

I'm using the Spring Boot launch script and I am not setting LOG_FOLDER a value.
I have configured logs using log4j.xml and passing log folder path while running the application which is working fine.But logs are being written to /var/log folder.
How to disable the default logging

not able to set spring active profile in tomcat

Tomcat8 is set to run as a service on ubuntu
I have deployed an application in tomcat8, I want the app to load(dev,local,prod)environment specific propety file
Which config file should I set -Dspring.profiles.active=\"prod\" value so the correct property file is read.
I tried in catalina.sh as JAVA_OPTS="$JAVA_OPTS -Dspring.profiles.active=\"prod\""
and also in /etc/default/tomcat8
In setenv.sh
CATALINA_OPTS="-Dspring.profiles.active=prod ...a whole bunch of stuff might already be here"

Resources