1

How to set show-sql to true once the Spring Boot Application has been started

We start application with spring.jpa.show-sql=false in src/main/resources/application.properties

If we need to momentarily turn on show-sql, how should we do it?

Rpj
  • 5,348
  • 16
  • 62
  • 122
  • Does this answer your question? [How can I log SQL statements in Spring Boot?](https://stackoverflow.com/questions/30118683/how-can-i-log-sql-statements-in-spring-boot) – XtremeBaumer Jul 25 '22 at 09:53
  • Also, [logback](https://logback.qos.ch/manual/configuration.html#conditional) supports conditionals. You might be able to dynamically set a variable there that is then properly evaluated. – XtremeBaumer Jul 25 '22 at 10:01
  • Its not the same, since I am asking how to manage it once the application is up and running without restarting the App – Rpj Jul 25 '22 at 14:57
  • Specifically [this answer](https://stackoverflow.com/a/60289026/7109162) includes solutions which might be possible to be adjusted to your needs. Also logbacks conditionals might be able to do what you need with `` to periodically reload the configuration – XtremeBaumer Jul 25 '22 at 14:58
  • The App is running inside a docker container, so it wouldn't be possible to modify or reload the file. How else to start or stop logging of the SQL – Rpj Jul 25 '22 at 15:02
  • Did you even read the answer I linked? There is no easy on the fly solution I am aware of. You need to implement a solution yourself, so start doing some research – XtremeBaumer Jul 25 '22 at 15:09

0 Answers0