简体   繁体   中英

slf4j with jdk14 is logging INFO messages to stderr

I am trying to get a grip of slf4j with jdk14. Weirdly, some INFO level messages are appearing in stderr.

I am executing the jar with the following command

java -Djava.util.logging.config.file=./src/main/resources/logging.properties -jar ./target/adwordsConnectorV2-account.jar

I am sure that they are INFO level, because when I set the property java.util.logging.ConsoleHandler.level to ALL , the messages show, but when it is set to SEVERE , they don't show.

Please can someone tell me why they might be logging to stderr instead of stdout?

Thanks

Ben


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

Here is what is logged to 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

EDIT: Here is what is in 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

I was seeing messages on stderr because that's the destination used by ConsoleHandler - see the ConsoleHandler javadoc here

The following post shows how to redirect the output, but that is kind of avoiding the problem How do I change java logging console output from std err to std out?

i have decided to switch to log4j instead as recommended by the google adwords team

I started to have the same issue after adding a new dependency (no code changes, no changes to the property file).

This new dependency was transitively pulling in sfl4j , and adding an exclusion in the pom file fixed the issue, as follows:

    <dependency>
      <groupId>org.apache.datasketches</groupId>
      <artifactId>datasketches-hive</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-simple</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM