Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change log level from command line?

Tags:

sbt

How can I change the log level in sbt at the command line without modifying the existing configuration?

like image 272
Radim Kolář Avatar asked Jun 10 '13 02:06

Radim Kolář


People also ask

How do I change the log level in console?

To change log levels as a root user, perform the following: To enable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=DEBUG) To disable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=INFO)

How do I change the log level in Linux?

You can change the logging level or trace level (also called the debug level) of a running process by sending a USR1 or USR2 signal to the process. Sending a USR1 signal changes the logging level and sending a USR2 signal changes the trace level.


2 Answers

As described in Change the logging level globally for sbt:

To set the logging level before any commands are executed on startup, use -- before the logging level

There are four logging levels:

  • debug
  • info
  • warn
  • error

If you need one applied "at the command line without modifying the existing configuration", execute the sbt launcher with appropriate level prefixed with double dashes.

jacek:~/oss/scalania
$ sbt --debug
[debug] > boot
[debug] > reload
[debug] > sbtStashOnFailure
[debug] > onFailure load-failed
[debug] > loadp
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[debug] Running task... Cancelable: false, check cycles: false
[debug]

With sbt.boot.properties you may get sbt internal logs printed out, too. See Launcher Specification.

like image 113
Jacek Laskowski Avatar answered Oct 09 '22 13:10

Jacek Laskowski


For SBT 0.12:

If you want to change the log level from the command line, you may do in sbt interactive mode without changing your build.sbt file or any configuration. Just type:

> set logLevel := Level.Debug

However if you are writing some scripts that will run in your server and you can't do interactively, you will have to create a boot.properties file setting the desired log level and pass this file in the command line, by running

sbt -Dsbt.boot.properties=path-to-your-boot.properties

Check the documentation for boot.properties here

like image 43
Vinicius Miana Avatar answered Oct 09 '22 14:10

Vinicius Miana