matomo-org / plugin-DeviceDetectorCache

Makes tracking in Matomo Analytics faster by detecting many devices, operating systems, bots, and browsers from a cache.
https://matomo.org
GNU General Public License v3.0
3 stars 7 forks source link

DeviceDetectorCache does not work with logs to stdout #16

Open mikkeschiren opened 3 years ago

mikkeschiren commented 3 years ago

I realize that maybe this a no-fix - but today many setups of Matomo is running in Kubernetes or Docker, and logs in many setups goes to stdout, is there any simple way to use this plugin in that context?

diosmosis commented 3 years ago

@mikkeschiren is this is a general matomo question or specific to DeviceDetectorCache? I don't see any output logging (apart from cli command output) in this plugin.

If for all of matomo, then it's possible to add logging to stdout via dependency injection. Adding something like this to /path/to/matom/config/config.php could work:

<?php

return [
    'log.handlers' => \DI\decorate(function ($previous) {
        $previous[] = new \Monolog\Handler\StreamHandler('php://stdout', Logger::WARNING);
        return $previous;
    }),
];
mikkeschiren commented 3 years ago

As I understand this plugin, it is using logs to warm the cache, and because of logs going to stdout in a normal docker setup, it is not usable, I think, in a docker environment.

tsteur commented 3 years ago

The plugin indeed only works on log files. The docker would somehow need to be configured to write log files for every tracking request and Matomo needs to be able to have read access. It won't work otherwise unfortunately.