javagroovyjava.util.loggingapache-commons-logginghttpbuilder

How to set up logging.properties for HTTPBuilder in Java


I'm trying to get the logs of my connection with HTTP Builder. I read a lot and heard to set up a configuration file. I'm executing my jar from the terminal with this command

java -jar -Djava.util.logging.config.file=logging.properties Console-0.1.jar

And my logging.properties looks like this

handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=ALL
.level=FINEST
httpclient.wire.header.level=FINEST
org.apache.commons.httpclient.level=FINEST

I don't get why it's not working. Has anyone an idea ?


Solution

  • I found a good and pretty easy solution. Just get the root Logger and set the level before the http builder gets called

        ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME)
        rootLogger.setLevel(level)