【问题标题】:How to disable google ads output in terminal如何在终端中禁用谷歌广告输出
【发布时间】:2022-03-11 04:53:34
【问题描述】:

我正在使用 google ads api 并在我们的网站上显示 Google adwords 广告。在每次请求时,终端都会显示日志记录请求和响应。我想知道有没有办法从控制台禁用请求/响应信息。我正在使用谷歌广告 java 库。 我尝试使用new RequestLogger 但我无法禁用它。 以下是我在每次 google ads api 调用时收到的给定消息类型。

com.google.api.client.http.HttpTransport [] - -------------- REQUEST  --------------
POST https://oauth.googleapis.com/token
Accept-Encoding: gzip
User-Agent: Google-HTTP-Java-Client/1.39.0 (gzip)
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 241
com.google.api.client.http.HttpTransport [] - curl -v --compressed -X POST -H 'Accept-Encoding: gzip' -H 'User-Agent: Google-HTTP-Java-Client/1.39.0 (gzip)' -H 'Content-Typ
e: application/x-www-form-urlencoded; charset=UTF-8' -d '@-' -- 'https://oauth2.googleapis.com/token' << $$$
com.google.api.client.http.HttpTransport [] - Total: 241 bytes
com.google.api.client.http.HttpTransport [] - client_id=xxxx&refresh_token=xxxx&grant_type=refresh_token
com.google.api.client.http.HttpTransport [] - -------------- RESPONSE --------------
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Alt-Svc: h3=":443"; ma=2592000,h3-29=":111"; ma=333,h3-T051=":3"; ma=000,h3-Q050=":443"; ma=2000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"
46,43"
Server: scaffolding on HTTPServer2
X-Content-Type-Options: nosniff
Pragma: no-cache

【问题讨论】:

    标签: logging ads google-ads-api ads-api


    【解决方案1】:

    Google 广告有多个级别的日志记录

        const ALERT     = 'alert';
        const CRITICAL  = 'critical';
        const ERROR     = 'error';
        const WARNING   = 'warning';
        const NOTICE    = 'notice';
        const INFO      = 'info';
        const DEBUG     = 'debug';
    

    默认的日志记录级别是信息。 对于 PHP,我们可以通过代码更改日志级别:

                ->from($configuration)
                ->withOAuth2Credential($oAuth2Credential)
                ->withLogLevel('error')
                ->build();
    

    或者在配置文件中设置。

    我相信你可以用 Java 做类似的事情

    【讨论】:

      猜你喜欢
      • 2019-11-17
      • 1970-01-01
      • 2011-10-16
      • 1970-01-01
      • 1970-01-01
      • 2022-08-20
      • 2016-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多