我试图用jdk14抓住slf4j。奇怪的是,一些INFO级别的消息出现在stderr中。
我正在使用以下命令执行jar
java -Djava.util.logging.config.file=./src/main/resources/logging.properties -jar ./target/adwordsConnectorV2-account.jar
我确信它们是INFO级别,因为当我将属性java.util.logging.ConsoleHandler.level
设置为ALL
时,会显示消息,但是当它设置为SEVERE
时,它们就会消失。 ; t show。
请有人告诉我为什么他们可能会登录到stderr而不是stdout?
由于
本
com.google.api的广告
ads-lib = 1.30.0
adwords-axis = 1.30.0
org.slf4j
slf4j-api = 1.7.7
slf4j-jdk14 = 1.7.7
以下是记录到stderr的内容:
Jul 18, 2014 3:42:11 AM com.google.api.ads.adwords.lib.utils.logging.ReportServiceLogger log
INFO: Request made: POST https://adwords.google.com//api/adwords/reportdownload/v201406
Jul 18, 2014 3:42:11 AM com.google.api.ads.adwords.lib.utils.logging.ReportServiceLogger log
INFO: accept-encoding: [gzip]
authorization: REDACTED
user-agent: [fetch-report (AwApi-Java, Common-Java/1.30.0, Java/1.6.0_31, maven)]
developertoken: REDACTED
clientcustomerid: XXXX
Parameters:
__rdxml: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><reportDefinition xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201406"><ns2:selector><ns2:fields>Date</ns2:fields><ns2:fields>AccountDescriptiveName</ns2:fields><ns2:fields>ExternalCustomerId</ns2:fields><ns2:fields>AccountCurrencyCode</ns2:fields><ns2:fields>Device</ns2:fields><ns2:fields>AverageCpc</ns2:fields><ns2:fields>AverageCpm</ns2:fields><ns2:fields>AveragePosition</ns2:fields><ns2:fields>Impressions</ns2:fields><ns2:fields>Clicks</ns2:fields><ns2:fields>Cost</ns2:fields><ns2:fields>Ctr</ns2:fields><ns2:fields>ConversionsManyPerClick</ns2:fields><ns2:dateRange><ns2:min>20140101</ns2:min><ns2:max>20141231</ns2:max></ns2:dateRange></ns2:selector><ns2:reportName>Account performance report</ns2:reportName><ns2:reportType>ACCOUNT_PERFORMANCE_REPORT</ns2:reportType><ns2:dateRangeType>CUSTOM_DATE</ns2:dateRangeType><ns2:downloadFormat>CSV</ns2:downloadFormat><ns2:includeZeroImpressions>false</ns
2:includeZeroImpressions></reportDefinition>
Jul 18, 2014 3:42:11 AM com.google.api.ads.adwords.lib.utils.logging.ReportServiceLogger log
INFO: Response received with status code 200 and message: OK
编辑:以下是logging.properties中的内容:
# from http://stackoverflow.com/questions/5416769/how-to-configure-the-jdk14-loggings-pattern
handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format = [%1$tc] %4$s: %2$s - %5$s %6$s%n
答案 0 :(得分:0)
我在stderr上看到了消息,因为这是ConsoleHandler使用的目标 - 请参阅ConsoleHandler javadoc here
以下文章介绍了如何重定向输出,但这有点避免了问题 How do I change java logging console output from std err to std out?
我决定转而使用log4j而不是as recommended by the google adwords team