aio logs not working

Avatar

Avatar

ursboller

MVP

Total Posts

1.0K

Likes

485

Correct Answer

250

Avatar

ursboller

MVP

Total Posts

1.0K

Likes

485

Correct Answer

250
ursboller
MVP

28-09-2020

since my latest update I can't see any logs of my actions - but they are working as expected in local environment. I hope I can provide enough information so somebody might see what I'm doing wrong ...

1) local environment, running "aio app run --local" and invoking an action shows me some log entries as expected:

ursboller_2-1601327359457.png

2) with no changes at all I then executed "aio app run" (no errors) and invoking the exact same action (with success in the UI), nothing happens in the logs. I checked the list with "aio runtime activation list" and could not find any new entries at all ... (which looks strange, what might be the issue?)

3) with no changes at all I then executed "aio app deploy" (no errors) and tried again the exact same action (again with success in the UI).

 

what is strange: at the same time I have an action triggered by whisk/alarms/interval which immediately starts after the app deploy. and this action executes as expected and I can see the entry in the "aio rt activation list" and fetch the logs with "aio rt activation logs ID". so the logs are not completely failing, just for my actions invoked by the web UI.

 

somehow, I managed to get the following error code, but can't tell what exactly I've done to get an activation entry ... maybe this helps: 

ursboller_1-1601327073471.png

and here are my settings from the package.json (only those I think must be mentioned)

 

    "@adobe/aio-lib-ims": "^4.1.1",
    "@adobe/aio-sdk": "^2.3.0",
    "@adobe/exc-app": "^0.2.21",
    "core-js": "^3.6.4",
    "ngrok": "^3.3.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1"
    "regenerator-runtime": "^0.13.5"

 

hopefully somebody can help me fix the issue ...

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

duypnguyen

Employee

Avatar

duypnguyen

Employee

duypnguyen
Employee

29-09-2020

Hi @ursboller - what you observed with no logs for web invocation is expected, because the logs are not automatically persisted. For debugging you could use a flag to force it. More background here: https://github.com/AdobeDocs/adobeio-runtime/blob/master/guides/logging_monitoring.md#retrieving-act...

HI @duypnguyen Thanks for the link - I don't understand. How can I force to see the logs for actions invoked by UI? do you have an example?

yes this is an example:

curl --location --request GET 'https://my-namespace-stage.adobeioruntime.net/api/v1/web/my-app-0.0.1/read-state?key=name' \
--header 'X-OW-EXTRA-LOGGING: on'
hi @duypnguyen is there a way to see the logs directly in console when using "aio app run" (similar to "--local")? what I would love to see is running the app and in the console I can see the debug logs (as in the screenshot above when using "--local"). sending curl request seems too complicated ...

Hi @ursboller, ok now I got your question. Indeed there are 2 points in it.

1. Log messages as direct output of the `aio app run (--local)` command. This is only possible in local mode as you pointed out. It is not possible in non-local mode because of the limitation in the second point below. In that case, you could do `aio app logs` to see logs.

2. Activation records and logs only persisted for async invocations (by default): this is the point I referred to in the earlier comment. Blocking invocations (e.g. web requests) are not recorded if they are successful. If you want to see logs, the web request must include the required header. The curl command just illustrates how you pass this header.

 

For SPA local development, I believe that there was an idea to automatically attach the logging header when you do `aio app run`. Let me follow up if there's something tangible for it.

Hi @duypnguyen 

We can see the error logs once in a while,


2020-09-29T11:33:21.427Z stdout: ERRROR-------------> FetchError: 401 Unauthorized ('No session is available for user xxxx@AdobeID') on GET https://reactor.adobe.io/companies
at Reactor.requestAndLog (/nodejsAction/hc9jf2d3/index.js:41608:13)

 

But most of the time there is nothing returned if use 'aio app logs'.

We already added the following header for the action invocation ( headers['X-OW-EXTRA-LOGGING'] = 'on').

Still no error logs, is anything missed from our end?

Hi @eldhov19157560 - do you have the activation ID of the invocation which you think there should be logs but not seeing them with `aio rt activation logs ID`?

 

In an SPA created by the Firefly generator with react spectrum, you can add the logging header to App.js so that it is enforced during your development:

async function actionWebInvoke (actionName, headers = {}, params = {}) {
  console.log('params.url = ', params)
  if (!actionName || !actions[actionName]) {
    throw new Error(`Cannot fetch action '${actionName}' as it doesn't exist.`)
  }
  const response = await fetch(actions[actionName], {
    method: 'post',
    headers: {
      'Content-Type': 'application/json',
      'x-ow-extra-logging': 'on',
      ...headers
    }
  }
}

 

@duypnguyen I will mark the question as answered, thanks gor the help. for my apps I have written a custom logger - basically writing the most important mesaages to aio-lib-files. this way, I can habe a custom screen showing all messages in my logger...

Answers (0)