# Capture Console Logs

**URL:** <https://forum.robotframework.org/t/capture-console-logs/4109>\
**Category:** Libraries\
**Created:** [29 June 2022 18:17 UTC](https://forum.robotframework.org/t/capture-console-logs/4109 "2022-06-29T18:17:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomaspekarovic](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/tomaspekarovic/32/1368_2.png) [@tomaspekarovic](https://forum.robotframework.org/u/tomaspekarovic)\
**Post date:** [29 June 2022 18:17 UTC](https://forum.robotframework.org/t/capture-console-logs/4109/1 "2022-06-29T18:17:27Z")

</div>

Hi again,

I’m trying to capture everything that is logged into console. I can save HAR file and parse network and get request/response/statuscode … but I need get output of console into file, or into variable, or to any point

I tried to do something like:

```
async function captureLogs(page, logger) {
  logger("Did I run?")
  page.on("console", (message) => {
    logger(message.text())
  })
}
exports.__esModule = true;
exports.captureLogs = captureLogs;

```

But this function just run (it is custom keyword), and does nothing else. (its js module) … Is there any way how to run this on background and listen on all events that happen? I run this keyword after the ‘New Page’ keyword is run.

I need information from console like:  
Service worker registration complete  
getting from server user  
[Violation] ‘setTimeout’ handler took 228ms

etc… lot of information that are shown only in console, so the HAR file does not contains them.  
Is there any way how to achieve this?

---

<div class="post-metadata">

**Author:** ![rasjani](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@rasjani](https://forum.robotframework.org/u/rasjani)\
**Post date:** [30 June 2022 11:12 UTC](https://forum.robotframework.org/t/capture-console-logs/4109/2 "2022-06-30T11:12:19Z")

</div>

Depending on the Browser and libs u use, SeleniumTestability has keyword to acquire Browsers console logs.

---

<div class="post-metadata">

**Author:** ![tomaspekarovic](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/tomaspekarovic/32/1368_2.png) [@tomaspekarovic](https://forum.robotframework.org/u/tomaspekarovic)\
**Post date:** [30 June 2022 11:17 UTC](https://forum.robotframework.org/t/capture-console-logs/4109/3 "2022-06-30T11:17:22Z")

</div>

Hm… Now I found out that this is not in the correct node of the forum. It it related to ‘Browser Library’

So my problem is with browser library itself. I can do it in selenium without any problems, but SeleniumTestability is not compatible with browser library. And as the Browser library is build uppon nodejs playwright I can’t find way how to just put some kind of listener to browser to capture logs.

thanks for reply
