My dropwizard logs are outputting everything to the console only and its outputting ALL levels of logging. I want to have some of the logging for my own stuff during development output to the console but filter out the noise. I've been stuck on this for a while and since I upgraded to dropwizard 1.0.5, my log output is too large and unusable to ignore this. I'm trying to filter logging but no matter what I do my configuration isn't used. when I run my dropwizard app I get ALL logging output to the console
I'm using the following command to start up
java \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=${JMX_PORT} \
-Dcom.sun.management.jmxremote.rmi.port=${JMX_PORT} \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Djava.rmi.server.hostname=${HOST_IP} \
-server \
-classpath "/server/api.jar:/server/config" \
-Dtm-devops.defaults.file=/server/config/local.properties \
-Xmx512m \
-Xms128m \
-Xdebug \
-Xrunjdwp:transport=dt_socket,server=y,suspend=${WAIT_DEBUG:-n},address=7878 \
com.tubemogul.api.Application server config.yaml
config.yaml is in the class patch and its the only yaml file in there. I can confirm an invalid change to this file is recognized and prevents the server from running.
I'm trying to apply the following logging configuration.
logging:
# The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
level: WARN
# Logger-specific levels.
loggers:
# Sets the level
io.dropwizard:
level: WARN
additive: false
appenders:
- type: file
currentLogFilename: log/dw.log
archivedLogFilenamePattern: log/dw.%d.log.gz
archivedFileCount: 5
org.eclipse: NONE
org.hibernate:
level: WARN
additive: false
appenders:
- type: file
currentLogFilename: log/hib.log
archivedLogFilenamePattern: log/hib.%d.log.gz
archivedFileCount: 5
org.springframework:
level: WARN
additive: true
appenders:
- type: file
currentLogFilename: log/spring.log
archivedLogFilenamePattern: log/spring.%d.log.gz
archivedFileCount: 5
appenders:
- type: console
threshold: WARN
using the configuration I've given the log files get created but they never get written to.
The first thing I have noticed on your configuration is that the level for the "org.eclipse" is incorrect as "NONE" is not an accepted level and this seems to be triggering all log messages from the "org.eclipse" logger to be shown in the console.
org.eclipse: NONE
Interesting enough, when I change the level of this logger to "OFF", I get an exception that the format of the logger is not supported. I have tried both without and with quotes on the logger name without luck as the error seems to be related to invalid JSON format. Which is strange because the DW documentation shows this format as supported.
org.eclipse: OFF
"org.eclipse": OFF
Exception in thread "main" java.lang.IllegalArgumentException: Unsupported format of logger 'org.eclipse'
When I change this logger to have the level attribute as a sub-attribute of the logger then DW accepts the format and I no longer getting the log messages in the console for this logger.
org.eclipse:
level: OFF
Having said that, the console appender with threshold WARN prevents all messages from going to console, both with the correct and incorrect levels. I am not sure if this helps but try to change the "org.eclipse" to another format and maybe that will help because I was not able to replicate the issue using DW 1.0.5 as all the messages are going to the correct place with right level.
P.S. I executed all the tests from Intellij, not from the command.