I have application-database.yml, application-sql.yml.Tried running using -Dspring.profiles.active=local but properties data not picking up. How to run this?
application-local.yml
spring:
profiles:
group:
local: database, sql, message
application:
name: HP-FETCHER-CONFIG-SERVICE
by Dspring.profiles.active=local you are telling spring that you use local profile, use Dspring.profiles.active=database instead
I'm not sure if this applies to your project:
just use application.yml,then:
spring:
profiles:
active: local, database, sql
---
spring:
profiles: local1
...
...
---
spring:
profiles: local
...
...
---
spring:
profiles: sql
...
...
---
spring:
profiles: database
...
...
when start without -Dspring.profiles.active it will use the local, database, sql. if start with -Dspring.profiles.active=local1,database,sql it will use the local1, database, sql
If you want to use group you have to specify it in either application.yml or application.properties file. The corresponding blog post says:
To define a group, you can use the spring.profiles.group property in your application.properties or application.yml file.
For me this seems to be working as expected. I have the below application.yml file
spring:
profiles:
group:
super-1-2: profile-1, profile-2
super-2-3: profile-2, profile-3
---
spring:
config:
activate:
on-profile:
- profile-1
---
spring:
config:
activate:
on-profile:
- profile-2
---
spring:
config:
activate:
on-profile:
- profile-3
If I run my application with profile super-1-2 activated, I get a confirmation in my logs that all three super-1-2, profile-1 and profile-2 are active.
2022-08-31 16:52:27.109 INFO 67935 --- [ restartedMain] c.s.n.SampleApplication : The following 3 profiles are active: "super-1-2", "profile-1", "profile-2"
On the other hand, if I run my application with profile super-2-3 activated, I get a confirmation in my logs that all three super-2-3, profile-2, and profile-3 are active.
2022-08-31 16:52:41.117 INFO 68090 --- [ restartedMain] c.s.n.SampleApplication : The following 3 profiles are active: "super-2-3", "profile-2", "profile-3"
I'm building a spring boot application. I'm trying to enable SQL logs in application.yml. How can I do it?
We can use any one of these:
spring:
jpa:
show_sql: true
or
logging:
level:
org:
hibernate:
sql=debug
type:
descriptor:
sql:trace
currently I'm trying to set trace logging level for internal JDK classes, especially for the new HttpClient.
When I add to my application.yaml:
logging:
level:
root: INFO
Everything logs in trace.
But when I want to enable trace logging only for JDK packages like:
logging:
level:
root: INFO
jdk.internal.net.http: TRACE
Those packages don't start log in trace, the entire app uses root level, which is INFO.
What do I need to solve this problem? Thanks guys.
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
My Java7 project uses c3p0 (0.9.5.1) for connection pooling and Log4j (1.2.17) for logging. It seems that log4j logs c3p0 INFO logs in ERROR level:
2017-02-09T21:30:19.545+01:00 app_r41 jsvclog[5135] err: JSVC [MLog-Init-Reporter] INFO com.mchange.v2.log.MLog - MLog clients using slf4j logging.
2017-02-09T21:30:19.959+01:00 app_r41 jsvclog[5135] err: JSVC [main] INFO com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.5.1 [built 16-June-2015 00:06:36 -0700; debug? true; trace: 10]
2017-02-09T21:30:21.294+01:00 app_r41 jsvclog[5135] err: JSVC [main] INFO com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource - [configuration of ComboPooledDataSource follows here...]
Now this is confusing and I want to disable it.
This is the relevant part of my log4j.properties configuration:
log4j.rootLogger=INFO, SYSLOG_APPENDER
log4j.logger.com.mchange=WARN, SYSLOG_APPENDER
What am I missing?
Setting this system property during service start-up fixes the problem:
System.setProperty( "com.mchange.v2.log.Log4jMLog.DEFAULT_CUTOFF_LEVEL", "WARNING" );