gpt4 book ai didi

java - slf4j 与 jdk14 正在将 INFO 消息记录到 stderr

转载 作者:行者123 更新时间:2023-12-02 00:07:03 25 4
gpt4 key购买 nike

我正在尝试通过 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,它们不会显示。

请有人告诉我为什么他们可能会记录到 stderr 而不是 stdout?

谢谢

<小时/>

com.google.api-ads

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

最佳答案

我在 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

关于java - slf4j 与 jdk14 正在将 INFO 消息记录到 stderr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24862751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com