0

I am using Magento 1.9 and want to redirect all the files generated inside the folder var/reports to stdout. If it is possible then how can I do it? If it is not then may be we can output all the generated reports files to one file and symlink to /dev/stdout. Any thoughts?

UPDATE:

I was able to create a file with name 9999 and redirect all logs to same file but when I tried to symlink the file to /dev/stdout or /proc/self/fd/1, both does not work. I still need the way to forward the logs to standard output.

To redirect logs to a single file, open errors/processor.php file and edit two lines

//$this->reportId   = abs(intval(microtime(true) * rand(100, 1000)));
$this->reportId   = 9999;

and

//@file_put_contents($this->_reportFile, serialize($reportData));
@file_put_contents($this->_reportFile, serialize($reportData).PHP_EOL,FILE_APPEND|LOCK_EX);

1 Answer 1

0

The problem is solved. I was actually applying this for kubernetes and I needed to log in stdout. I followed the above updated steps and then use another container as sidecar, then tail the output of 9999. It then gave me what I wanted.

I know this is not where I ask devops stuff but here is what sidecar container look like

        - image: busybox
          name: report-log
          command: ["/bin/sh"]
          args:
          - -c
          - |
            mkdir -p  /var/www/html/var/report
            touch /var/www/html/var/report/9999
            chown 33:33 /var/www/html/var -R
            chmod 777 /var/www/html/var/ -R
            tail -n+1 -f /var/www/html/var/report/9999
          resources:
            limits:
              cpu: 5m
              memory: 64Mi
            requests:
              cpu: 5m
              memory: 64Mi
          volumeMounts:
          - name: reportlog
            mountPath: /var/www/html/var/report

Also do not forget to mount volume as emptyDir. You can get the example here: https://kiwee.eu/magento-2-on-kubernetes/

2
  • Since I was using kubernetes, I managed to solved it using kubernetes approach. If it can be solved by magento itself then please feel free to leave your comments.
    – Prakash
    Sep 2, 2020 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.