braintree / braintree_java

Braintree Java library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
158 stars 98 forks source link

Change log level #46

Closed asib closed 7 years ago

asib commented 7 years ago

How do I change the log level? I'd like it to be set to Level.FINE so that I can see the response codes for all requests, and I attempted to do this using the following snippet:

BraintreeGateway gateway = new BraintreeGateway(Environment.SANDBOX,
    BTMerchantAccountID,
    BTPublicKey,
    BTPrivateKey);
gateway.getConfiguration().getLogger().setLevel(Level.FINE);

However, this did not work, and I still only saw logs with level >= Level.INFO. Would be grateful for a solution.

jdlc commented 7 years ago

The java.util.logging library requires both a logger's level and a handler's level to be set, you will also need to change whatever handler you are using's level to at least Level.FINE. If you are using a ConsoleHandler, the snippet would look like this:


Logger logger = gateway.getConfiguration().getLogger();
logger.setLevel(Level.FINE);
ConsoleHandler handler = new ConsoleHandler();
handler.setLevel(Level.FINE);
logger.addHandler(handler);
logger.fine("I love Braintree");

Closing this issue.