Server logs are not being created

I’ve set up logging according to the FAQ (How do I view Piwik application logs? - Analytics Platform - Piwik)

However, no log files appear in the logging dir (/opt/bitnami/apps/piwik/htdocs/tmp/logs)

This is what I added to the config.ini.php:
[log]
log_writers[] = file
log_level = INFO
logger_file_path = tmp/logs/piwik.log

I restarted everything, that didn’t help either. Not sure what to do next. I need the logs to debug another problem I’m having.

Hi,

Do you know if the webserver/PHP has write permission in this folder? Have you tried the LogViewer Plugin?

Hi Lukas. Yes I installed the plugin, which gives an error message: “Specified path to log file does not exist: /opt/bitnami/apps/piwik/htdocs/tmp/logs/piwik.log”

Which is correct, since the file doesn’t exist.

Everything is installed by bitnami and uses the user daemon:
drwxr-xr-x 2 daemon daemon 4096 Dec 10 08:02 logs/

All directories are created by the same user.

Hi,

The only thing I can think of it the following note in the FAQ:

The Monolog Plugin must be activated in your Piwik server, you can check it by going to Administration > Plugins.

And maybe check the PHP error log if it provides more details.

The Monolog Plugin was already activated.

The PHP error doesn’t show any problems regarding writing to the log files :frowning:

Hello,

I am having the exact same issue. Matomo configuration seem to be correct since everything is working fine, except the fact that the LogViewer is giving me this error “Specified path to log file does not exist: /opt/matomo/tmp/logs/matomo.log”. Matomo.log file indeed doesn’t exist. matomo/tmp file has write permissions and the config.ini.php file is configured correctly to write logs into this file.

I had the same issue. I solved by providing write permission to tmp and logs folder and then I created manually the file matomo.log in tmp/logs/. It worked for me.

I have created the file myself but matomo still doesn’t write anything to it. I have given full permissions (0777) to the folder and the file.

I’m having the same problem. I followed all the suggestions, still no logs.

Hi everyone,

Can you try applying this change:

diff --git a/plugins/Monolog/config/config.php b/plugins/Monolog/config/config.php
index 4d5e3d15a3..ff60f7c5bd 100644
--- a/plugins/Monolog/config/config.php
+++ b/plugins/Monolog/config/config.php
@@ -38,12 +38,7 @@
 
         $writerNames = array_map('trim', $writerNames);
 
-        $writers = [
-            // we always add the null handler to make sure there is at least one handler specified. otherwise Monolog will
-            // add a stream handler to stderr w/ a DEBUG log level, which will cause archiving requests to fail.
-            $c->get(\Monolog\Handler\NullHandler::class),
-        ];
-
+        $writers = [];
         foreach ($writerNames as $writerName) {
             if ($writerName === 'screen' && \Piwik\Common::isPhpCliMode()) {
                 continue; // screen writer is only valid for web requests
@@ -77,6 +72,12 @@
             $writers[] = $c->get(LogCaptureHandler::class);
         }
 
+        // we always add the null handler to make sure there is at least one handler specified. otherwise Monolog will
+        // add a stream handler to stderr w/ a DEBUG log level, which will cause archiving requests to fail.
+        if (empty($writers)) {
+            $writers[] = $c->get(\Monolog\Handler\NullHandler::class);
+        }
+
         return array_values($writers);
     }),

This should be included in the next Matomo release and fix this issue.

That fixed it for me. Thanks!

1 Like

I applied this change. also I done the config setting, but still no logs.

please, help.

After applying the change, download the LogViewer plugin, refresh the logs from the plugin, and then it should create the log file.