cancel
Showing results for 
Search instead for 
Did you mean: 

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.

 

zappullae59
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

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

4 REPLIES 4

@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.
Lilith
Administrator Administrator
Administrator

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?

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

 

zappullae59
Contributor

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