0

In spite of using Logger.log()method, nothing is displayed in the Log-box. What should I do to show log messages in log-box?

After I sent message to chatbot using webhook(there is no problem. my chatbot return messages), I check log-box(above "Stackdriver Logging").but there is no message.

Add, use console.log instead of logger.log, i could watch logs on Stackdriverlogging. thanks.

var ACCESS_TOKEN = 'ACCESS_TOKEN_VALUE';

function doPost(e) {
  var replyToken = JSON.parse(e.postData.contents).events[0].replyToken;
  var userMessage = JSON.parse(e.postData.contents).events[0].message.text;
  var url = 'https://api.line.me/v2/bot/message/reply';

  UrlFetchApp.fetch(url, {
    'headers': {
      'Content-Type': 'application/json; charset=UTF-8',
      'Authorization': 'Bearer ' + ACCESS_TOKEN,
    },
    'method': 'post',
    'payload': JSON.stringify({
      'replyToken': replyToken,
      'messages': [{
        'type': 'text',
        'text': userMessage + 'ンゴ',
      }],
    }),
    });
  Logger.log(userMessage.toString()); 
  return ContentService.createTextOutput(JSON.stringify({'content': 'post ok'})).setMimeType(ContentService.MimeType.JSON);
}
TheMaster
  • 45,448
  • 6
  • 62
  • 85
tetris
  • 3
  • 3
  • 1
    use console.log and stackdriver – TheMaster Mar 29 '20 at 17:42
  • i could get logs on Stackdriverlogging show using console.log()method. thanks – tetris Mar 29 '20 at 22:25
  • Does this answer your question? [Debug a Google Apps Script which is triggered by post request?](https://stackoverflow.com/questions/54772207/debug-a-google-apps-script-which-is-triggered-by-post-request) – Rubén May 25 '20 at 19:35

0 Answers0