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

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

Related

Spring Boot Log initialization with Spring Cloud Kubernetes

Spring Boot 2.2.6-RELEASE
In my application.yml, I have this line :
logging.config: classpath:my-logback-config.xml
This works well, spring get its config nicely
In my my-logback-config.xml I have this line :
<springProperty name="LOG_HOST" source="config.logHost" />
<springProperty name="LOG_PORT" source="config.logPort" />
Again, this works well, it get its value from an external config file, which is defined in a ENV variable
SPRING_CONFIG_ADDITIONAL_LOCATION=file:/my-env.properties
But when I enable Spring Cloud Kubernetes, this fails, with an UnknowHostException : "LOG_HOST_IS_UNDEFINED" cannot be resolved. (the value of LOG_HOST is used to setup a network appender)
Why does enabling Spring Cloud Kubernetes change the behavior of logging initialization?
It seem that values from SPRING_CONFIG_ADDITIONAL_LOCATION are not loaded yet.
I can't load this value from a configMap, since Spring Cloud Kubernetes has not been initialized at the moment logging is being initialized.
Finally, the problem was that the ENV var SPRING_CONFIG_ADDITIONAL_LOCATION was set to a folder, and not to a file on container.
Locally, on windows, setting 'SPRING_CONFIG_ADDITIONAL_LOCATION' to either a file or a folder seems to work, but in the Docker image (RH linux), it has an impact.
When SPRING_CONFIG_ADDITIONAL_LOCATION is set to a folder, values of the enclosed ".properties" files are ignored.
I can reproduce (fix) the issue by changing my docker file :
ENV SPRING_CONFIG_ADDITIONAL_LOCATION="/mnt/properties/application.properties"
to
ENV SPRING_CONFIG_ADDITIONAL_LOCATION="/mnt/properties/"

Spring Cloud Config Server Not picking changes

I am trying to setup spring config cloud using local file system.
Below is my config on cloud server.
server.port=8888
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=classpath:/
Bootstrap.properties on client app is as shown below
spring.application.name=hello-world
spring.cloud.config.uri=http://localhost:8888
management.endpoints.web.exposure.include=*
I have also created hello-world.yml on class path for the hello-world spring boot application with property, test: Hello World
Followed below steps to make use of config server.
Step 1: Update the config file and start cloud config server. Able to
see config http://localhost:8888/hello-world/default
Step 2: Start client app hello-world, client app able to read the
test property file from cloud config server.
Step 3: Make changes to config by updating test: Good Bye on
hello-world.yaml.
At this moment, if I check
http://localhost:8888/hello-world/default ,it still shows old value.
Step 4: Run /actuator/refresh on client app. But it won't detect
any change on config server.
The new changes are reflected only if I restart the cloud config server.
Is there any configuration issue causing the cloud config server to unable to listen to changes ?
I could see o.s.cloud.commons.util.InetUtils : Cannot determine local hostname INFO log on cloud config app.
First of all I followed the same exact steps you followed and got the same issue, after almost day of search and study on the matter found out the followings,
we shouldn't use classpath:/<whatever> for
spring.cloud.config.server.native.searchLocations
because when we use so and build the project and run the location refers to the directory inside the generated .jar file, so we will not be able to update it in runtime.
To confirm this you can stop config server, open you .jar archive and delete hello-world.yml file then try http://localhost:8888/hello-world/default you will get default null responses
So we have to use some other locations for spring.cloud.config.server.native.searchLocations either with full directory path or just directory from app running location
Examples
For full path in windows use file:///full-path
spring.cloud.config.server.native.searchLocations: file:///E:\configs
Just for a directory (which will search project root directory if you running from IDE, if running jar then target directory or jar location spring.cloud.config.server.native.searchLocations: configs
spring.cloud.config.server.native.searchLocations: configs\whatever
we can configure multiple locations too as follows, spring.cloud.config.server.native.searchLocations: file:///E:\configs, configs

log4j2 logs for Spring boot application inside Docker container

I have a spring boot application which uses log4j2 to write logs. When I deploy this application to a Docker container, I want the logs to be written to a file at a specified location outside the container. How can I do this ? I tried providing the path of the log folder using an environment variable on startup but its of no use. No logs are being written. Please help
You have to mount the directory on the host file system inside the container. A simple web search will yield many results on how to do this such as How to mount a host directory in a Docker container

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!

spring boot log file being overwritten on restart

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!

Resources