Community
OpenEnergyMonitor

Community

Emoncms.log location

hello

I get The log file has no write permissions or does not exists. To fix, log-on on shell and do:
touch /var/log/emoncms/emoncms.log
chmod 666 /var/log/emoncms/emoncms.log

But in /var/www/emoncms/settings.php:
$log_filename = ‘/var/log/emoncms.log’;

The log file is indeed in /var/log

but why does the admin page insists the log file should be in /var/log/emoncms?

I grepped all the files but I could not find the hard reference to that

If it is there, can you please post the Server Information from the admin page (Copy as Markdown button).

Server Information

Server Information

Services

  • emonhub :- Active Running
  • mqtt_input :- Active Running
  • feedwriter :- Active Running - sleep 60s 133 feed points pending write
  • service-runner :- Active Running
  • emonPiLCD :- Active Exited
  • redis-server :- Active Running
  • mosquitto :- Active Running

Emoncms

  • Version :- low-write 10.1.6
  • Modules :- Administration | App v2.0.6 | Backup v1.1.5 | EmonHub Config v2.0.4 | Dashboard v2.0.4 | Device v2.0.1 | EventProcesses | Feed | Graph v2.0.4 | Input | Postprocess v1.0.0 | CoreProcess | Schedule | Network Setup v1.0.0 | sync | Time | User | Visualisation | WiFi v2.0.1
  • Git :-

Server

  • OS :- Linux 4.19.66-v7+
  • Host :- emonpi | emonpi | (192.168.12.43)
  • Date :- 2019-10-04 11:28:00 EEST
  • Uptime :- 11:28:00 up 7 days, 18:15, 0 users, load average: 0.16, 0.12, 0.09

Memory

  • RAM :- Used: 17.87%
    • Total :- 975.62 MB
    • Used :- 174.37 MB
    • Free :- 801.25 MB
  • Swap :- Used: 0.00%
    • Total :- 100 MB
    • Used :- 0 B
    • Free :- 100 MB

Disk

  • / :- Used: 44.63%
    • Total :- 3.81 GB
    • Used :- 1.7 GB
    • Free :- 1.93 GB
  • /boot :- Used: 52.50%
    • Total :- 42.52 MB
    • Used :- 22.32 MB
    • Free :- 20.19 MB
  • /home/pi/data :- Used: 6.43%
    • Total :- 3.21 GB
    • Used :- 211.06 MB
    • Free :- 2.84 GB

HTTP

  • Server :- Apache/2.4.25 (Raspbian) HTTP/1.1 CGI/1.1 8043

MySQL

  • Version :- 5.5.5-10.1.23-MariaDB-9+deb9u1
  • Host :- localhost:6379 (127.0.0.1)
  • Date :- 2019-10-04 08:27:59 (UTC 00:00‌​)
  • Stats :- Uptime: 670502 Threads: 2 Questions: 148485 Slow queries: 0 Opens: 43 Flush tables: 1 Open tables: 37 Queries per second avg: 0.221

Redis

  • Version :- 3.2.6
  • Host :- localhost:6379
  • Size :- 77 keys (741.69K)
  • Uptime :- 7 days

MQTT Server

  • Version :- Mosquitto 1.4.10
  • Host :- localhost:1883 (127.0.0.1)

PHP

  • Version :- 7.0.33-0+deb9u3 (Zend Version 3.0.0)
  • Modules :- apache2handler | calendar v7.0.33-0+deb9u3 | Core v7.0.33-0+deb9u3 | ctype v7.0.33-0+deb9u3 | curl v7.0.33-0+deb9u3 | date v7.0.33-0+deb9u3 | dom v20031129 | exif v7.0.33-0+deb9u3 | fileinfo v1.0.5 | filter v7.0.33-0+deb9u3 | ftp v7.0.33-0+deb9u3 | gd v7.0.33-0+deb9u3 | gettext v7.0.33-0+deb9u3 | hash v1.0 | iconv v7.0.33-0+deb9u3 | igbinary v2.0.1 | json v1.4.0 | libxml v7.0.33-0+deb9u3 | mbstring v7.0.33-0+deb9u3 | mcrypt v7.0.33-0+deb9u3 | mosquitto v0.4.0 | mysqli v7.0.33-0+deb9u3 | mysqlnd vmysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $ | openssl v7.0.33-0+deb9u3 | pcre v7.0.33-0+deb9u3 | PDO v7.0.33-0+deb9u3 | pdo_mysql v7.0.33-0+deb9u3 | Phar v2.0.2 | posix v7.0.33-0+deb9u3 | readline v7.0.33-0+deb9u3 | redis v4.1.1 | Reflection v7.0.33-0+deb9u3 | session v7.0.33-0+deb9u3 | shmop v7.0.33-0+deb9u3 | SimpleXML v7.0.33-0+deb9u3 | sockets v7.0.33-0+deb9u3 | SPL v7.0.33-0+deb9u3 | standard v7.0.33-0+deb9u3 | sysvmsg v7.0.33-0+deb9u3 | sysvsem v7.0.33-0+deb9u3 | sysvshm v7.0.33-0+deb9u3 | tokenizer v7.0.33-0+deb9u3 | wddx v7.0.33-0+deb9u3 | xml v7.0.33-0+deb9u3 | xmlreader v7.0.33-0+deb9u3 | xmlwriter v7.0.33-0+deb9u3 | xsl v7.0.33-0+deb9u3 | Zend OPcache v7.0.33-0+deb9u3 | zlib v7.0.33-0+deb9u3

Pi

  • Model :- Raspberry Pi 3 Model B+ Rev 1.3 - 1GB (Sony UK)

  • Serial num. :- 189B6A75

  • Temperature :- 45.62°C - 46.2°C

  • emonpiRelease :- emonSD-30Oct18

  • File-system :- read-write

Client Information

Client Information

HTTP

  • Browser :- Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
  • Language :- en-US,en;q=0.9,ro;q=0.8

Window

  • Size :- 1841 x 1009

Screen

  • Resolution :- 1920 x 1080

My suspicion is that this is because the variable $log_filename became $log_location

Is there a folder /var/log/emoncms/? It should be created by one of the services at startup.

I think if you change the line

$log_filename = '/var/log/emoncms.log';

to

$log_location = "/var/log/emoncms";

it should be happy.

https://github.com/emoncms/emoncms/pull/1308#issuecomment-501244517 refers

These sort of issues should be overcome by the hierarchical settings that have been introduced.

If this doesn’t fix it, try

sudo systemctl restart emoncms_mqtt.service

and post output from

sudo systemctl status emoncms_mqtt.service

no, your line did not work

but this one inspired by yours worked:

$log_location = ‘/var/log’;
$log_filename = ‘emoncms.log’;

the problem is now it does not find emonpiupdate.log :slight_smile:

/var/log/emonpiupdate.log does not exist

it’s actually in /home/pi/data

That’s because in modules/admin/admin_controller.php:
$emoncms_logfile = $settings[‘log’][‘location’]."/emoncms.log";
$update_logfile = $settings[‘log’][‘location’]."/emonpiupdate.log";
$backup_logfile = $settings[‘log’][‘location’]."/emonpibackup.log";

from what I see, you can’t have logs in different locations
I could hard edit $emoncms_logfile in the php file, but that would be an ugly fix

I don’t have emoncms_mqtt.service

[email protected]:/var/www/emoncms# systemctl | grep mqtt
mqtt_input.service loaded active running Emoncms MQTT Input Script
[email protected]:/var/www/emoncms# systemctl | grep emoncms
[email protected]:/var/www/emoncms#

LATER EDIT:
I did a full update and now I do have that script

● emoncms_mqtt.service - Emoncms emoncms_mqtt script
Loaded: loaded (/var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-10-04 20:09:42 EEST; 4s ago
Docs: https://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/MQTT.md
Process: 16231 ExecStartPre=/bin/chmod 666 ${LOG_PATH}/emoncms.log (code=exited, status=0/SUCCESS)
Process: 16227 ExecStartPre=/bin/touch ${LOG_PATH}/emoncms.log (code=exited, status=0/SUCCESS)
Process: 16224 ExecStartPre=/bin/chown ${USER} ${LOG_PATH} (code=exited, status=0/SUCCESS)
Process: 16218 ExecStartPre=/bin/mkdir -p ${LOG_PATH} (code=exited, status=0/SUCCESS)
Main PID: 16234 (php)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/emoncms_mqtt.service
└─16234 /usr/bin/php /var/www/emoncms/scripts/services/emoncms_mqtt/emoncms_mqtt.php

I changed the log location to /home/pi/data, where the other log files are and it seems to work as all files are in the same place now

$log_location = '/home/pi/data';
$log_filename = 'emoncms.log';

Because

Now you have the emoncms_mqtt.service the correct folder, /var/log/emoncms should be created and the permissions set correctly (on startup).

You would now be better with

$log_location = "/var/log/emoncms";

As:

  1. That is where emoncms expects to be.
  2. If the logs are on /home/pi/data, it is increasing the wear on the SD card so making this more prone to early failure. /var/log is mounted on tempfs for this reason.
  3. Additionally, the logfiles will grow uncontrolled as logrotate will not find them there.

YMMV

Cheers

indeed now everything works as expected

thanks :slight_smile:

Did you change the log_location to /var/log/emoncms?