How to configure logger level to FINEST for Wildfly Swarm - java

I have followed this guide for project*.yml.
I created two files under src/main/resources:
project-default.yml which contains:
logger:
level: INFO
swarm:
http:
port: 80
and project-dev.yml which contains:
logger:
level: FINEST
swarm:
http:
port: 8080
I have successfully switched between them by using the flagg -Dswarm.project.stage=dev, verifying that the port is actually changed.
By some reason when using the dev-profile the application refuses to logg anything logged with logger.finest(...) while when using logger.info(...) it is logged correctly.
Did I configure the logging levels incorrectly? In that case, how should they be configured?

This is wrong:
logger:
level: WHATEVER
For logging, Wildfly Swarm relies on the logging WildFly subsystem, similarly to other functionalities. So the correct YAML snippet is:
swarm:
logging:
...
For example:
swarm:
logging:
root-logger:
level: FINE

Related

How to get multiple Consul KVs from different Consul context?

I have these KVs sources store on Consul:
config/books/<key>
config/common/<key>
And in my spring boot app application.yml, I have config it as following:
spring:
application:
name: sampleapp
cloud:
consul:
host: localhost
port: 8500
config:
enabled: true
prefix: config
defaultContext: books
I know that this configuration that I made has pointed the app to read from config/books .
But I can't figure out how can I retrieve the Consul KV config from both config/common and config/books.
It's not really flexible there, but it can be done if you rename your project and use defaultContext as well. Based on the documentation Spring Cloud Consul Config takes next paths:
config/testApp,dev/
config/testApp/
config/application,dev/
config/application/
where testApp - name of your app, application - default context
So with the following configuration it will work
spring:
application:
name: books
cloud:
consul:
host: localhost
port: 8500
config:
enabled: true
prefix: config
defaultContext: common
Logs after running this configuration:
Located property source: CompositePropertySource {name='consul', propertySources=[ConsulPropertySource {name='config/books/'}, ConsulPropertySource {name='config/common/'}]}

Spring Cloud Kubernetes fails setting ConfigMap values

I am trying to support K8s ConfigMap API using Spring to handle my externalized configuration. I've been using a configuration service without any issues, so I don't believe it is a cloud-config implementation problem. I am using version 1.0.2.RELEASE of spring-cloud-starter-kubernetes-config.
My ConfigMap consists of two configurations: global (application.yml) and app-specific yaml (myapp.yml). Here is what that looks like:
apiVersion: v1
kind: ConfigMap
metadata:
name: myapp-config
data:
application.yml: |-
kafka:
hosts: kafka:9092
topics:
events: myapp-events
normalized: myapp-normalized
#...
storage:
uri: mongodb://mongo-0.mongo:27017,mongo-1.mongo:27017,mongo-2.mongo:27017
database: do-stuff-db
#...
spring:
cloud:
config:
override-system-properties: false
#...
myapp.yml: |-
myapp:
broadcast-address: 0.0.0.0:666
#...
application.yml seems to work just fine. I can see the configuration values in my application but for whatever reason, myapp.yml does not get set. I can see Spring is successfully grabbing the entire result from the ConfigMap API but it does not do anything with myapp.yml.
Turning on debug logging exposed how Spring is interpreting the ConfigMap result. It is treating the entire myapp.yml section as one property and not its own property source. This explains why the application.yml is taking and not the myapp.yml. Here is what that log looks like (I have truncated the message):
2019-09-04 14:01:37.083 [main] INFO config.PropertySourceBootstrapConfiguration - Located property source: CompositePropertySource {name='composite-configmap', propertySources=[ConfigMapPropertySource#92864491 {name='configmap.myapp-config.default', properties={kafka.hosts=kafka:9092, kafka.topics.events=myapp-events, kafka.topics.normalized=myapp-normalized, myapp.yml=myapp:
bind-address: 0.0.0.0:666
#...
storage.uri: mongodb://mongo-0.mongo:27017,mongo-1.mongo:27017,mongo-2.mongo:27017, storage.database: do-stuff-db}}]}
Do I need to separate these configurations? The examples I've seen from Spring suggest you could consolidate your configuration into a single YAML ConfigMap file. I am stumped.

Spring Boot Admin does not detect service after restarting

I have an environment with different services. They all are deployed and managed by Docker images and Kubernetes. I also use spring-boot-admin in order to monitor them all and spring-cloud-kubernetes to discover all the services automatically.
This my properties file.
application.yml (In the SBA project)
server:
port: ${admin-server.port:8086}
tomcat:
remote-ip-header: x-forwarded-for
protocol-header: x-forwarded-proto
spring:
application:
name: admin-server
security:
user:
name: ${spring-security.admin.username:****}
password: ${spring-security.admin.password:****}
boot:
admin:
discovery:
ignored-services: admin-server
notify:
mail:
enabled: ${admin-mail.enabled:true}
to: ${admin-mail.recipients:******}
from: ${admin-mail.from:******}
template: classpath:/template/status-changed.html
ignore-changes: OFFLINE:UP, DOWN:UP
slack:
webhook-url: ${admin-slack.webhook:*******}
ignore-changes: OFFLINE:UP, DOWN:UP
enabled: true
mail:
test-connection: false
host: smtpjc.*****
port: 25
properties:
mail:
smtp:
connectiontimeout: 5000
timeout: 3000
writetimeout: 5000
debug: ${admin-mail.debug:true}
It works perfectly whenever I restart the SBA project, it discovers every service.
My problem comes when I restart a single project, it is shown as OFFLINE in the SBA and it does not change its status.
What am I missing?
I have found the issue and fixed it like this:
spring.cloud.kubernetes.reload.enabled: true
I should have added this line to the config file.
I've found out, that I had to use the fabric8 kubernetes-client.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-kubernetes-fabric8-all</artifactId>
</dependency>
I'm using these current versions:
<spring-cloud.version>2020.0.2</spring-cloud.version>
<spring-cloud-kubernetes.version>2.0.2</spring-cloud-kubernetes.version>
<spring-boot-admin.version>2.4.1</spring-boot-admin.version>
Otherwise I follow the instructions of https://piotrminkowski.com/2020/02/18/spring-boot-admin-on-kubernetes/

How can define subfolder to look for config files for jhipster registry

I just ran jhipster registry and its working fine. It's looking for config files from central-config folder. I want to refactor my config files under folders in the central-config folder itself. That's something that I can achieve running Spring Cloud Config server with a configuration like this:
spring:
cloud:
config:
server:
git:
default-label: develop
uri: file://${user.home}/config-repo
search-paths: employee-service, enterprise-service
How can I achieve such behavior with 'composite thing' in jhipster-registry. For info, this is the bootstrap.yml file from jhipster registry:
# ===================================================================
# Spring Cloud Config bootstrap configuration for the "dev" profile
# In prod profile, properties will be overwriten by the ones defined in bootstrap-prod.yml
# ===================================================================
spring:
application:
name: jhipster-registry
profiles:
active: dev
include: composite
cloud:
config:
server:
bootstrap: true
composite:
- type: native
search-locations: file:./central-config
#search-locations: file://${user.home}/Acensi/isupplier/config-repo
prefix: /config
fail-fast: true
# name of the config server's property source (file.yml) that we want to use
name: jhipster-registry
profile: dev # profile(s) of the property source
label: master # toggle to switch to a different version of the configuration as stored in git
# it can be set to any label, branch or commit of the config source git repository
info:
project:
version: #project.version#
# uncomment to enable encryption features
#encrypt:
# key: my-secret-encryption-key-to-change-in-production
I had the same issue. I added to my application.yml file the following:
spring:
cloud:
config:
server:
bootstrap: true
composite:
- type: native
search-locations: file:./central-config/myFolder
You were very close, hope it helps.
I was upgrading an existing older JHipster Registry to 5.0.1. I was also using the git repo. The problem with the above configurations is that the property is not called search-locations for the git repo it is search-paths. In order to keep everything working as before which was had the search paths specified via an environment variable SPRING_CLOUD_CONFIG_SERVER_GIT_SEARCH-PATHS, I use the following configuration in my prod bootstrap.
bootstrap-prod.yml:
spring:
cloud:
config:
server:
bootstrap: true
composite:
- type: git
uri: git#bitbucket.org:whatever/repo
search-paths: ${spring.cloud.config.server.git.search-paths}
ignore-local-ssh-settings: true
private-key: |
-----BEGIN RSA PRIVATE KEY-----

Spring Boot Application Hanging When Running on Command Line

I have a Spring Boot app that can not be run with a .yml config file.Below is the command that I run:
java -jar /opt/myAppFolder/myApp.war
I have a config folder withing the same location that I run my war file. And in that config,I have a application.yml file that application needs to retrieve some config:
security:
user:
password: password
logging:
level:
org.springframework.security: DEBUG
release:
sourceDir: /$ANY_DIR
targetDir: /$ANY_DIR
users:
- name: $ANY_NAME
pwd : $ANY_NAME
- name: $ANY_NAME
pwd : $ANY_NAME
mail:
host: $ANY_NAME
recipients: $ANY_NAME
subject: $ANY_NAME
body: $ANY_NAME
server:
port: 9000
spring:
profiles:
active: prod
Problem: Once I run the app on command line,the process just hangs.No output,no logging. I have tried to enable debug via command line. No avail.
If I put a file with properties extension,it works.However I want to use .yml since it is more convenient for me to have list of dynamic properties.And why nothing is displayed anway?
Any help appreciated.
Spring Boot Version:1.5.7
OS Version:Ubuntu 3.13.0-24-generic
Finally resolved it.
So here is the story:
I have contacted Spring Boot Team and they have recommended me to upgrade to version 1.5.8.RELEASE.
Once I did that,I had a different issue;application was not hanging anymore,but shutting down without logging anything.
And eventually it turned out to be an error in my logback-spring.xml file. It was malformatted.And in its "prod" profile,I did not have any console appender.Hence no output visible. So I have fixed my file and it started working.
More on my communication with Spring Boot Team:
https://github.com/spring-projects/spring-boot/issues/10711

Categories