Seham Hammad
asked on
Log files in snappy ubuntu core
Hello
where is the logs files are stored in the snap that runs on edge boxes with ubuntu core 16.04
Thanks in advance
where is the logs files are stored in the snap that runs on edge boxes with ubuntu core 16.04
Thanks in advance
ASKER
I have tried that but it gives me the live logs and I am looking for the logs should include the status where the system has been disconnected.
Thanks very much for your reply.
Thanks very much for your reply.
Likely...
And any software can log anywhere, so if you're looking for a specific log (sometimes logs end up the oddest places), mention the exact log you're missing + likely someone can pass along where it lives.
/var/log
And any software can log anywhere, so if you're looking for a specific log (sometimes logs end up the oddest places), mention the exact log you're missing + likely someone can pass along where it lives.
ASKER
here is my code, the connectionLog.txt in the Logs folder, but the snap doesn't find the file location, how will let it know the location of the file
#!/usr/bin/env node
const moment = require('moment');
const shutdown = require('electron-shutdown -command') ;
const electron = require('electron');
const fs = require('fs');
let counter = 0;
function checkInternet(cb) {
setInterval(function(){
require('dns').lookup('goo gle.com',f unction(er r) {
if (err && err.code === "ENOTFOUND") {
cb(false);
} else {
cb(true);
}
}); }, 30000);
}
function rebootEdgeBox(){
shutdown.reboot();
console.log('Shutting down now');
}
checkInternet(function (isConnected) {
if (isConnected) {
console.log('alive');
counter =0;
} else {
const timeStamp = moment().format('YYYY-MM-D D, HH:mm:ss');
const status = 'Disconnected at ' + timeStamp;
console.log(status);
counter += 1;
vortexLog(status);
if (counter === 10){
counter = 0;
console.log('ji');
rebootEdgeBox();
}
}
});
function vortexLog(string) {
fs.appendFile('./Logs/conn ectionLog' , string + "\r\n", function (err) {
if (err) throw err;
});
}
#!/usr/bin/env node
const moment = require('moment');
const shutdown = require('electron-shutdown
const electron = require('electron');
const fs = require('fs');
let counter = 0;
function checkInternet(cb) {
setInterval(function(){
require('dns').lookup('goo
if (err && err.code === "ENOTFOUND") {
cb(false);
} else {
cb(true);
}
}); }, 30000);
}
function rebootEdgeBox(){
shutdown.reboot();
console.log('Shutting down now');
}
checkInternet(function (isConnected) {
if (isConnected) {
console.log('alive');
counter =0;
} else {
const timeStamp = moment().format('YYYY-MM-D
const status = 'Disconnected at ' + timeStamp;
console.log(status);
counter += 1;
vortexLog(status);
if (counter === 10){
counter = 0;
console.log('ji');
rebootEdgeBox();
}
}
});
function vortexLog(string) {
fs.appendFile('./Logs/conn
if (err) throw err;
});
}
You're using a relative path (./Logs/connectionLog) which will never work... unless you have your code switch to /var/log as it's working directory at runtime. A very bad idea.
Just change your path to /var/log/connection/foo.lo g or whatever you name your log.
Also not, you should use lowercase log rather than Logs, else you'll be storing your logs completely outside the system log area.
Just change your path to /var/log/connection/foo.lo
Also not, you should use lowercase log rather than Logs, else you'll be storing your logs completely outside the system log area.
ASKER
Thanks very much fro your reply, will try this right now and will let you know
ASKER
Just tried your solution but this what I keep getting:
Disconnected at 2019-02-19, 14:31:39
Feb 19 14:31:39 seham-VirtualBox ping-check-microservice.pi ng-check-m icroservic e[7892]: /snap/ping-check-microserv ice/x11/li b/node_mod ules/check connectivi ty/checkCo nnectivity .js:57
Feb 19 14:31:39 seham-VirtualBox ping-check-microservice.pi ng-check-m icroservic e[7892]: if (err) throw err;
Feb 19 14:31:39 seham-VirtualBox ping-check-microservice.pi ng-check-m icroservic e[7892]: ^
Feb 19 14:31:39 seham-VirtualBox ping-check-microservice.pi ng-check-m icroservic e[7892]: Error: ENOENT: no such file or directory, open '/var/log/mylogs/connectio n.log'
Feb 19 14:31:39 seham-VirtualBox systemd[1]: snap.ping-check-microservi ce.ping-ch eck-micros ervice.ser vice: Main process exited, code=exited, status=1/FAILURE
Feb 19 14:31:39 seham-VirtualBox systemd[1]: snap.ping-check-microservi ce.ping-ch eck-micros ervice.ser vice: Failed with result 'exit-code'.
Feb 19 14:31:39 seham-VirtualBox systemd[1]: snap.ping-check-microservi ce.ping-ch eck-micros ervice.ser vice: Service hold-off time over, scheduling restart.
Feb 19 14:31:39 seham-VirtualBox systemd[1]: snap.ping-check-microservi ce.ping-ch eck-micros ervice.ser vice: Scheduled restart job, restart counter is at 1.
Feb 19 14:31:39 seham-VirtualBox systemd[1]: Stopped Service for snap application ping-check-microservice.pi ng-check-m icroservic e.
Feb 19 14:31:39 seham-VirtualBox systemd[1]: Started Service for snap application ping-check-microservice.pi ng-check-m icroservic e.
Feb 19 14:31:41 seham-VirtualBox ping-check-microservice.pi ng-check-m icroservic e[8518]: Disconnected at 2019-02-19, 14:31:41
Feb 19 14:31:41 seham-VirtualBox ping-check-microservice.pi ng-check-m icroservic e[8518]: /snap/ping-check-microserv ice/x11/li b/node_mod ules/check connectivi ty/checkCo nnectivity .js:57
Feb 19 14:31:41 seham-VirtualBox ping-check-microservice.pi ng-check-m icroservic e[8518]: if (err) throw err;
Disconnected at 2019-02-19, 14:31:39
Feb 19 14:31:39 seham-VirtualBox ping-check-microservice.pi
Feb 19 14:31:39 seham-VirtualBox ping-check-microservice.pi
Feb 19 14:31:39 seham-VirtualBox ping-check-microservice.pi
Feb 19 14:31:39 seham-VirtualBox ping-check-microservice.pi
Feb 19 14:31:39 seham-VirtualBox systemd[1]: snap.ping-check-microservi
Feb 19 14:31:39 seham-VirtualBox systemd[1]: snap.ping-check-microservi
Feb 19 14:31:39 seham-VirtualBox systemd[1]: snap.ping-check-microservi
Feb 19 14:31:39 seham-VirtualBox systemd[1]: snap.ping-check-microservi
Feb 19 14:31:39 seham-VirtualBox systemd[1]: Stopped Service for snap application ping-check-microservice.pi
Feb 19 14:31:39 seham-VirtualBox systemd[1]: Started Service for snap application ping-check-microservice.pi
Feb 19 14:31:41 seham-VirtualBox ping-check-microservice.pi
Feb 19 14:31:41 seham-VirtualBox ping-check-microservice.pi
Feb 19 14:31:41 seham-VirtualBox ping-check-microservice.pi
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
You can use journalctl for this.
read up here .
Cheers