matomo-org / matomo-log-analytics

Import any kind of server logs in Matomo for powerful log analytics. Universal log file parsing and reporting.
https://matomo.org/log-analytics/
GNU General Public License v3.0
224 stars 118 forks source link

import_logs.py : ValueError: can't have unbuffered text I/O #318

Closed Fluoo closed 3 years ago

Fluoo commented 3 years ago

Hello,

I have made a migration of my website to a new server. I also update matomo from 3.x to the last 4.3.1 . Before the migration everything was fine, after migration and update I have an error : Traceback (most recent call last): File "/home/lesgrand/www/administration/matomo/misc/log-analytics/import_logs.py", line 2666, in config = Configuration() File "/home/lesgrand/www/administration/matomo/misc/log-analytics/import_logs.py", line 1028, in init self._parse_args(self._create_parser(), argv) File "/home/lesgrand/www/administration/matomo/misc/log-analytics/import_logs.py", line 938, in _parse_args sys.stdout = sys.stderr = open(self.options.output, 'a+', 0) ValueError: can't have unbuffered text I/O

I have multiple site and all site have the same problem. I use a custom log format in apache so I use this command to import log : python /home/lesgrand/www/administration/matomo/misc/log-analytics/import_logs.py --url=XXXXXXXXX --idsite=7 --log-format-regex='(?P[\w.:-]+)\s+\S+\s+\S+\s+"(?P.?)"\s+"(?P\S+)\s+(?P[^"]+)\s+\S+"\s+(?P\d+)\s+(?P\S+)\s+"(?P.?)"\s+"(?P.?)".' --log-date-format="%Y/%m/%d %H:%M:%S" --exclude-path=/administration/ --output=/var/log/matomo.log /var/log/apache2/ifbe-access.log

python --version Python 3.8.10

Matomo 4.3.1 Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-77-generic x86_64)

Thanks

diosmosis commented 3 years ago

Hi @Fluoo, can you try replacing the import_logs.py script with the latest in this repository: https://raw.githubusercontent.com/matomo-org/matomo-log-analytics/4.x-dev/import_logs.py and see if it works?

Fluoo commented 3 years ago

Hello,

It works with the dev version.

It seems that it's the same version in the 4.4.0

Thanks