Unable to write the logs to the console and log file using spring boot 1.5.3 - spring

I am using the Spring boot 1.5.3 release and for logs, I am using the default spring boot logging.
I didn't add any extra dependencies for this and added the below properties to my application.properties file.
logging.level.org.springframework.web=info
logging.level.com.mypackage.service.*=debug
logging.level.root=info
logging.pattern.console=%d{dd-MM-yyyy HH:mm:ss.SSS} %magenta([%thread]) %highlight(%-5level) %logger.%M - %msg%n"
But the spring logs are writing to the console and application logs are not writing to the console and "System.out.println" also not printing in the console while deploying the application in tomcat.
Kindly provide me how to resolve this issue and print system out statements.

Wildcard is not needed there, this will be sufficient
logging.level.com.mypackage.service=debug
Remember that if you have your root on info level, then no debug logs will come whatsoever, so debug logs from com.mypackage.service will be suppressed.

Try to include the starter loggin dependency. It's included by default in all the spring starters projects but I cannot see your pom so I'm not sure about your pom configuration.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>

Related

h2database login screen not working in my spring application

I am using h2dabase as in memory database in my application.
I have added following dependency in my pom.xml file.
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
Following is my application.properties
spring.application.name=currency-exchange-service
server.port=8000
spring.jpa.show-sql=true
spring.h2.console.enabled=true
Following is the error I am getting on the browser:
To reproduce the error, I've downloaded a fresh Spring boot project with the spring-boot-starter-web and h2 modules. When using your settings, the URL was inaccessible just like your screenshot showed.
The URL did became accessible when I added
spring.h2.console.path=/h2-console to application.properties.

Breakpoints and maven options are ignored when using spring devtools

I'm trying to use spring devtools for my project. When I add devtools dependency breakpoints stopped working and maven options are ignored. I'm using Netbeans.
I added dependency into pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
And this is the netbeans action for debug:
Executed goal: spring-boot:run
Profile: dev
Properties:
jpda.listen=maven
Env.MAVEN_OPTS=-Dflyway.enabled=false
Breakpoints and maven options (MAVEN_OPTS) are working fine without devtools dependency. Adding the devtools dependency causes "-Dflyway.enabled=false" option and breakpoints being ignored. The maven command with all arguments generated by Netbeans is the same, I can see it in the log output. Is there anything else I have to set for devtools?
I found the answer, the properties in action must be written this way (spring boot 2.0.0):
spring-boot.run.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Dspring.flyway.enabled=false
jpda.listen=true
For spring boot version < 2.0.0 it is:
run.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Dflyway.enabled=false
jpda.listen=true

intelij spring boot hot swap causes context reload

I am using Intellij 2017.2 with Spring Boot 1.5.4
When I recompile my current class with ctr+shift+F9, instead of the IDE doing a bytecode hotswap, the spring container gets reloaded.
On top of that, after the reload my RestConroller no longer works
I have tried adding / removing from my pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
please advise
I am not sure if this is a spring boot bug as of the new version, but I ended up disabling manually the hot reload via properties:
This is done by setting the following in your application.properties:
spring.devtools.restart.enabled=false
The official doc:
https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html#using-boot-devtools-restart-disable

Create a Spring Boot 1.5.8 Quartz scheduler app

I want to create a Spring Boot Quartz scheduler app. using Spring Boot 1.5.8 with Spring Tool Suite Version: 3.9.0.RELEASE using the option Spring Starter Project, but the Quartz scheduler option is disabled:
I also tried to added manually adding to the pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
and then I got the error:
Project build error: 'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-quartz:jar is
missing.
You have to create your spring-boot starter app with version >= 2.0.0.M2. At start.spring.io you can see for which version some dependencies are available.
After using the correct version, everything should work.

Spring Boot 2 with actuator

i'm using spring boot 2.0.0.M3 with the spring-boot-starter-actuator. I enabled two health checks:
management.health.diskspace.enabled=true
management.health.mongo.enabled=true
The healt check beans are created by the auto configure, but not the HealthMvcEndpoint. The response of localhost:8080/health is 404.
What did I do wrong?
Thanks in advance
EDIT:
Mhm do the actuator project works with reactive and webflux?
Ok found this issue:
https://github.com/spring-projects/spring-boot/issues/7970
according to the documentations for 2.0.0M the actuator endpoints have been prefixed with /application so they become /application/health instead.
You should also be able to see all this in the info logs about the endpoints, when booting up your application
https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#production-ready-endpoints
also an actual release note about it:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0.0-M1-Release-Notes#actuator-default-mapping
I'm using webflux+springboot 2.0.2.RELEASE.
Checking the logs I found that it is actuallu under /actuator now.
so: http://localhost:8080/actuator/health will work
Add this to your application.properties file:
management.endpoints.web.base-path=/
The actuator endpoints will now be '/health'
Include the spring-boot-starter-web dependency in your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

Resources