How do I do logging in a cli Command?

45 views
Skip to first unread message

Josh Rehman

unread,
May 25, 2020, 5:59:27 PM5/25/20
to dropwizard-user
Hi there,

I'm writing a CLI using dropwizard and want to log some stuff during processing. However, my Command doesn't seem to pick up the config.yml settings for logging, and I'm not sure why.
Note that logging does work in my code, but only at the "WARN" level and above (which is probably a default somewhere).

My application is hosted at https://github.com/javajosh/csv-demo

Thanks for your help!

javajosh

unread,
May 26, 2020, 12:25:31 AM5/26/20
to dropwizard-user
After digging around in Dropwizard source, I was able to produce a workaround where I can override the Bootstrap log level in the Application subclass. However, I still can't modify appenders, etc.

Dimas Guardado

unread,
May 26, 2020, 8:12:37 PM5/26/20
to dropwizard-user
Hi Josh,


It looks like if you extend `ConfiguredCommand` instead of `Command` it'll make your config available to your command, and it should initialize logging using the config: https://github.com/dropwizard/dropwizard/blob/master/dropwizard-core/src/main/java/io/dropwizard/cli/ConfiguredCommand.java#L83

Does that work in your case?
Reply all
Reply to author
Forward
0 new messages