# Logging from Extensions

**URL:** <https://forum.genieacs.com/t/logging-from-extensions/540>\
**Category:** Uncategorized\
**Created:** [January 6, 2020, 7:25pm UTC](https://forum.genieacs.com/t/logging-from-extensions/540 "2020-01-06T19:25:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ekreckel](https://avatars.discourse-cdn.com/v4/letter/e/a183cd/32.png) [@ekreckel](https://forum.genieacs.com/u/ekreckel)\
**Post date:** [January 6, 2020, 7:25pm UTC](https://forum.genieacs.com/t/logging-from-extensions/540/1 "2020-01-06T19:25:25Z")

</div>

Good day,

I am working on spinning up a new installation of GenieACS 1.2 due to its automation abilities. At this time, I’m working on an extension script and I am not being successful in getting it to log debugging information anywhere.

GenieACS is installed on a Ubuntu 19 server utilizing the recommended installation method from the GenieACS docs. Therefore, my extension scripts are located in /opt/genieacs/ext. In order to make any libraries load, I created the directory /opt/genieacs/lib and placed a copy of all the libraries in this location.

The first problem is I am unable to load the logger with require("…/lib/logger"); I must specify the full “/opt/genieacs/lib/logger” path. Even then, occasionally, the script will error out with the message:  
Channel has faulted; channel=“test” retries=0 faultCode=“ext.Error” faultMessage=“Cannot find module ‘/opt/genieacs/lib/logger’”

I can clear the fault and re-trigger the script and it will work fine the next time. Should I not be using the GenieACS logger library and use a NodeJS logger library instead?

2nd, when the logger does load and the script runs, there is no log output anywhere. I’m sure this is a noob question, but how do I make the extension log to a file so I can debug and know what is happening?

-Eric

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [January 6, 2020, 10:05pm UTC](https://forum.genieacs.com/t/logging-from-extensions/540/2 "2020-01-06T22:05:08Z")

</div>

I use v1.1 still and use console.log in my extension scripts. Try that and see how that works for you.

---

<div class="post-metadata">

**Author:** ![ekreckel](https://avatars.discourse-cdn.com/v4/letter/e/a183cd/32.png) [@ekreckel](https://forum.genieacs.com/u/ekreckel)\
**Post date:** [January 8, 2020, 9:45pm UTC](https://forum.genieacs.com/t/logging-from-extensions/540/3 "2020-01-08T21:45:23Z")

</div>

Hello,

I was able to get this working in v1.2 by using console.log and using journalctl in follow mode (-f) against the genieacs-cwmp daemon (-c genieacs-cwmp) to view the extension messages. Thanks for the poke in the proper direction.

Eric

---

<div class="post-metadata">

**Author:** ![fonz](https://avatars.discourse-cdn.com/v4/letter/f/7ba0ec/32.png) [@fonz](https://forum.genieacs.com/u/fonz)\
**Post date:** [July 20, 2020, 11:45pm UTC](https://forum.genieacs.com/t/logging-from-extensions/540/4 "2020-07-20T23:45:47Z")

</div>

Hi Eric,  
I too am having the same issue of not seeing the log message from the extensions.  
I am using v1.2  
I am running the extension script described in the documentation: http://docs.genieacs.com/en/latest/extensions.html  
and I’ve added one “console.log” to test the logging from the extension.

* * *

“use strict”;

const http = require(“http”);

let cache = null;  
let cacheExpire = 0;

function latlong(args, callback) {  
if (Date.now() \< cacheExpire)  
return callback(null, cache);

http.get(“[http://api.open-notify.org/iss-now.json](http://api.open-notify.org/iss-now.json)”, (res) =\> {  
if (res.statusCode !== 200)  
return callback(new Error(`Request failed (status code: ${res.statusCode})`));

```
let rawData = "";
res.on("data", (chunk) => rawData += chunk);

res.on("end", () => {
  console.log('received data from OSS'); <-- see this
  let pos = JSON.parse(rawData)["iss_position"];
  cache = [+pos["latitude"], +pos["longitude"]];
  cacheExpire = Date.now() + 10000;
  callback(null, cache);
});

```

}).on(“error”, (err) =\> {  
callback(err);  
});  
}

## exports.latlong = latlong;

I know that this script runs successfully because I see the returned values in the provision script that 's calling the extension.

I tried running this to view the messages from the extension:  
journalctl -u genieacs-cwmp.service -f

However, I do not see the log message from the extension anywhere.

thanks !
