Reply
Highlighted
Contributor
Posts: 42
Registered: ‎09-26-2015
Accepted Solution

Logging Level

So, I have ANet integrated well into my system and would like to turn down the logging level for just card processing, not the entire system.  Is this possible and if so how do I do it?  I'm using Java / Tomcat / log4j and AIM.

 


Accepted Solutions
Solution
Accepted by topic author zappullae59
‎11-15-2016 09:16 AM
Contributor
Posts: 42
Registered: ‎09-26-2015

Re: Logging Level -- SOLVED

So after much experimenting and observation of the log output I have figured this out. As it turns out the documentation for HttpClient on the Apache HTTPCLient website is not correct (as a matter of fact there are broken links). It turns out the names of the loggers used by HTTPClient are not as specified in the doc. The correct logger root name is "http" not "httpclient" which means all the trials I was performing had zero effect.

 

I am using org.apache.httpcomponents.httpclient_4.5.2 and org.apache.httpcomponents.httpcore_4.4.5 which as of today (11/15/16) I believe is the latest implantation.

 

Here is an example log4j.properties file that will allow fine control of the HTMLClient logging

 

# Tell the root logger what appenders and level to use
log4j.rootLogger=DEBUG, A1, A2


# Controls detailed wire protocol
log4j.logger.org.apache.http.wire=WARN

# Controls headers (good for debugging)
log4j.logger.org.apache.http.headers=WARN

# Controls http context (what you are sending and geting)
log4j.logger.org.apache.http=WARN

# Controls htmlunit details
log4j.logger.com.gargoylesoftware.htmlunit=WARN


##### Console Appender #####

log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n


##### File Appender #####

log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.File=mylogfile.log
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n
log4j.appender.A2.Append=false

View solution in original post


All Replies
Posts: 321
Topics: 5
Kudos: 36
Blog Posts: 5
Ideas: 0
Solutions: 26
Registered: ‎11-09-2011

Re: Logging Level

@zappullae59 I presume you are referring to disabling log4j.logger.net.authorize.util.HttpClient entirely, but leave log4j.logger.net.authorize.sim.TransactionTest enabled. Is that correct?


https://github.com/AuthorizeNet/sdk-java/blob/master/resources/log4j.properties

 

If not, could you elaborate a bit further, please?

 

 

--
"Move fast and break things," out. "Move carefully and fix what you break," in.
Contributor
Posts: 42
Registered: ‎09-26-2015

Re: Logging Level

[ Edited ]

I want to reduce the logging output to WARN for AIM in a production enviornment.  I don't have an AIM specific logger defined in my lor4j.properties so I'm guessing its using the default logger.  Would I be correct in assuming I need to define the logger and set the level to WARN in my log4j.properties file?

Contributor
Posts: 42
Registered: ‎09-26-2015

Re: Logging Level

[ Edited ]

So I have this configuration in my log4j.properties file but I still get DEBUG output from ANET on the console and the log file, anet.log, is not created.  What logger is ANET using?  Am I configuring the wrong one?

 

log4j.rootLogger=DEBUG, A1, A2, ANET

 

log4j.logger.net.authorize.util.HttpClient=FATAL, ANET
log4j.logger.net.authorize.sim.TransactionTest=FATAL, ANET

log4j.appender.ANET=org.apache.log4j.FileAppender

log4j.appender.ANET.File=anet.log
log4j.appender.ANET.layout=org.apache.log4j.PatternLayout
log4j.appender.ANET.layout.ConversionPattern=%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n

 

 

https://github.com/AuthorizeNet/sdk-java/blob/master/resources/log4j.properties

 

Solution
Accepted by topic author zappullae59
‎11-15-2016 09:16 AM
Contributor
Posts: 42
Registered: ‎09-26-2015

Re: Logging Level -- SOLVED

So after much experimenting and observation of the log output I have figured this out. As it turns out the documentation for HttpClient on the Apache HTTPCLient website is not correct (as a matter of fact there are broken links). It turns out the names of the loggers used by HTTPClient are not as specified in the doc. The correct logger root name is "http" not "httpclient" which means all the trials I was performing had zero effect.

 

I am using org.apache.httpcomponents.httpclient_4.5.2 and org.apache.httpcomponents.httpcore_4.4.5 which as of today (11/15/16) I believe is the latest implantation.

 

Here is an example log4j.properties file that will allow fine control of the HTMLClient logging

 

# Tell the root logger what appenders and level to use
log4j.rootLogger=DEBUG, A1, A2


# Controls detailed wire protocol
log4j.logger.org.apache.http.wire=WARN

# Controls headers (good for debugging)
log4j.logger.org.apache.http.headers=WARN

# Controls http context (what you are sending and geting)
log4j.logger.org.apache.http=WARN

# Controls htmlunit details
log4j.logger.com.gargoylesoftware.htmlunit=WARN


##### Console Appender #####

log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n


##### File Appender #####

log4j.appender.A2=org.apache.log4j.FileAppender
log4j.appender.A2.File=mylogfile.log
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=%d %-5p [%t] %-17c{2} (%13F:%L) %3x - %m%n
log4j.appender.A2.Append=false