Dropwizard Admin: Change loglevel for all

前端 未结 1 1291
旧时难觅i
旧时难觅i 2021-01-06 04:07

My config is the standard

logging:

  # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
  level: INFO

  # Logger-spec         


        
相关标签:
1条回答
  • 2021-01-06 04:31

    I've checked the source code for the log-level task and its main logic is implemented like this:

    for (String loggerName : loggerNames) {
        ((LoggerContext) loggerContext).getLogger(loggerName).setLevel(loggerLevel);
        output.println(String.format("Configured logging level for %s to %s", loggerName, loggerLevel));
        output.flush();
    }
    

    So the way it's implemented is based on the name for the logger, knowing this I went into the source for org.slf4j.Logger interface and found this field:

    String ROOT_LOGGER_NAME = "ROOT";
    

    Doing a POST like this solved it for me:

    curl -X POST -d "logger=ROOT&level=DEBUG" localhost:8081/tasks/log-level
    
    0 讨论(0)
提交回复
热议问题