nextcloud / logreader

📜 Log reader for Nextcloud
57 stars 27 forks source link

Error while opening /dev/stdout #1217

Closed myxor closed 6 months ago

myxor commented 6 months ago

Steps to reproduce

  1. Use Nextcloud FPM docker container image
  2. Configure 'logfile' => '/dev/stdout',
  3. Open Log in administrator settings, see empty log and HTTP Status 500 for apps/logreader/api/poll?lastReqId= request in browser console

Expected behaviour

Log should be filled with log entries

Actual behaviour

Log stays empty and i see this in docker logs:

NOTICE: PHP message: {"reqId":"hjr6qSydnYtY9pfRvwuj","level":3,"time":"2024-04-16T12:08:16+00:00","remoteAddr":"62.214.75.82","user":"marco","app":"index","method":"GET","url":"/apps/logreader/api/poll?lastReqId=","message":"Error while opening /dev/stdout","userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0","version":"28.0.4.1","exception":{"Exception":"Exception","Message":"Error while opening /dev/stdout","Code":0,"Trace":[{"file":"/var/www/html/apps/logreader/lib/Controller/LogController.php","line":83,"function":"getLogIterator","class":"OCA\\LogReader\\Log\\LogIteratorFactory","type":"->","args":[[0,1,2,3,4]]},{"file":"/var/www/html/apps/logreader/lib/Controller/LogController.php","line":110,"function":"getLastItem","class":"OCA\\LogReader\\Controller\\LogController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"poll","class":"OCA\\LogReader\\Controller\\LogController","type":"->","args":[""]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":137,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\LogReader\\Controller\\LogController"],"poll"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\LogReader\\Controller\\LogController"],"poll"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\LogReader\\Controller\\LogController","poll",["OC\\AppFramework\\DependencyInjection\\DIContainer"],["logreader.log.poll"]]},{"file":"/var/www/html/lib/base.php","line":1069,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/logreader/api/poll"]},{"file":"/var/www/html/index.php","line":39,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/apps/logreader/lib/Log/LogIteratorFactory.php","Line":58,"message":"Error while opening /dev/stdout","exception":{},"CustomMessage":"Error while opening /dev/stdout"}}

Server configuration

Official Nextcloud FPM docker image

Database: Postgresql

PHP version: 8.2.18

Nextcloud version: (see Nextcloud admin page)

Where did you install Nextcloud from: Official Nextcloud FPM docker image

List of activated apps:

If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your Nextcloud installation folder

Nextcloud configuration:

{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.1.11",
            "cloud.marcoheiming.de",
            "192.168.1.2"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "28.0.4.1",
        "overwrite.cli.url": "https:\/\/cloud.marcoheiming.de",
        "overwritehost": "cloud.marcoheiming.de",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "loglevel": 1,
        "logfile": "\/dev\/stdout",
        "maintenance": false,
        "overwriteprotocol": "https",
        "mail_smtpauth": 1,
        "check_data_directory_permissions": false,
        "app_install_overwrite": [
            "keeporsweep",
            "apporder",
            "news",
            "files_markdown"
        ],
        "theme": "",
        "default_phone_region": "DE",
        "preview_max_x": "512",
        "preview_max_y": "512",
        "jpeg_quality": {
            "occ": {
                "config:app:set": {
                    "preview": {
                        "jpeg_quality": "60"
                    }
                }
            }
        }
    }
}

Client configuration

Browser:

Operating system:

Logs

Nextcloud log (data/owncloud.log)

NOTICE: PHP message: {"reqId":"tynzh2mm5bakBwyJHpYe","level":3,"time":"2024-04-16T12:15:57+00:00","remoteAddr":"XXX","user":"marco","app":"PHP","method":"GET","url":"/apps/logreader/api/poll?lastReqId=","message":"fopen(/dev/stdout): Failed to open stream: No such file or directory at /var/www/html/apps/logreader/lib/Log/LogIteratorFactory.php#51","userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0","version":"28.0.4.1","data":{"app":"PHP"}}

NOTICE: PHP message: {"reqId":"tynzh2mm5bakBwyJHpYe","level":3,"time":"2024-04-16T12:15:57+00:00","remoteAddr":"XXX","user":"marco","app":"index","method":"GET","url":"/apps/logreader/api/poll?lastReqId=","message":"Error while opening /dev/stdout","userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:122.0) Gecko/20100101 Firefox/122.0","version":"28.0.4.1","exception":{"Exception":"Exception","Message":"Error while opening /dev/stdout","Code":0,"Trace":[{"file":"/var/www/html/apps/logreader/lib/Controller/LogController.php","line":83,"function":"getLogIterator","class":"OCA\\LogReader\\Log\\LogIteratorFactory","type":"->","args":[[0,1,2,3,4]]},{"file":"/var/www/html/apps/logreader/lib/Controller/LogController.php","line":110,"function":"getLastItem","class":"OCA\\LogReader\\Controller\\LogController","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":230,"function":"poll","class":"OCA\\LogReader\\Controller\\LogController","type":"->","args":[""]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":137,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\LogReader\\Controller\\LogController"],"poll"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[["OCA\\LogReader\\Controller\\LogController"],"poll"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":315,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\LogReader\\Controller\\LogController","poll",["OC\\AppFramework\\DependencyInjection\\DIContainer"],["logreader.log.poll"]]},{"file":"/var/www/html/lib/base.php","line":1069,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/apps/logreader/api/poll"]},{"file":"/var/www/html/index.php","line":39,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/apps/logreader/lib/Log/LogIteratorFactory.php","Line":58,"message":"Error while opening /dev/stdout","exception":{},"CustomMessage":"Error while opening /dev/stdout"}}

Browser log

From browser console:

XHRGET
https://NEXTCLOUD_URL/apps/logreader/api/poll?lastReqId=
[HTTP/2 500  256ms]

[WARN] logreader: Unexpected error while polling for new log entries 
Object { app: "logreader", level: 1, error: {…} }
​
app: "logreader"
​
error: Object { stack: "ge@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:153625\nwv@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:164964\nm@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:168156\nEventHandlerNonNull*Pv</<@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:168228\nPv<@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:167133\ni1@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:170929\nrequest@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:174594\nv0.prototype[e]@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:174899\na4/<@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:148348\nf1@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:193078\nm@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:421878\nsetTimeout handler*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\nasync*m@https://NEXTCLOUD_URL/apps/logreader/js/logreader-main.mjs?v=7b303b73-14:2:422219\n", message: "Request failed with status code 500", name: "AxiosError", … }
​
myxor commented 6 months ago

After opening this issue i found the solution myself.

Thanks to this comment https://github.com/nextcloud/docker/issues/2119#issuecomment-1855710640 i found this in the Nextcloud administrator manual: https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/config_sample_php_parameters.html#log-type:

I needed to change the Nextcloud config log settings to:

  'log_type' => 'file',
  'logfile' => 'syslog',

Now the log is inside the container and in Nextcloud logreader.

Closing this issue.