opcodesio/log-viewer

Remote Host configured but logs are not loaded nor shown

Opened this issue · 9 comments

Hi i have setup your log-viewer package inside my development environment.

two projects have the package installed and if i have understood it correctly
Project A (mainly the log-viewer) can access a remote host Project B (https://log-viewer.opcodes.io/docs/3.x/configuration/multiple-hosts)

config in Project A
'hosts' => [ 'local' => [ 'name' => ucfirst(env('APP_ENV', 'local')), ], 'projectB.ddev.site' => [ 'name' => 'projectB.ddev.site', 'host' => 'http://projectB.ddev.site/log-viewer', ], ],

config in Project B the remote host
`
'enabled' => env('LOG_VIEWER_ENABLED', true),

'api_only' => env('LOG_VIEWER_API_ONLY', true),

'require_auth_in_production' => false,

......

'hosts' => [
    'local' => [
        'name' => ucfirst(env('APP_ENV', 'local')),
    ],

],
`
no other var was changed
i have cleared the application cache

i can call the log-viewer url/api in my browser correctly when the api_only is set to false
if api_only is set to true the same url result in 404 not found, i would have expected an denied ?

also i can call the api via curl in console run curl projectb.ddev.site/log-viewer/api/folders etc it responds

when opening in project A inside my browser and switching via dropdown to the project b host, it looks it is loading something, but the ui remains the same, folders are unchanged and no files from project b are visible.

therefore i have checked the browser network analysis tab
after switch to host B, i can see there is a json response with an object which download_url seems to be the project b, but it responds with the local (project a) files.

i have configured project b with http: as it seems to have trouble with self signed testing cert, but in the download url it is using https:

am i doing something wrong here?
i do not see any error inside the laravel.log

any help is appreciated, and thanks for the good work

PS: for anyone also having issues using the custom log types, the docs seems not to be complete, take a look at the laravelLogLevel class and copy what is needed

@kantmn maybe you should re-look the config.
My suggessition are try with a fresh laravel install first. Hope you find some help.

@bhagat-abhishek well this is a fresh install already, and as far is see i followed the config guide.
that is why opened this support thread, to receive help.

i made it simpled, disable the authentication and only added the remote host to the config and added the package to the target host.

if you see the error please tell me

Project A config has a host that points to ProjectA as well. Shouldn't it point to Project B instead?

sorry for the delay. i had no time to investigate this, but i promise to post back once i do.

sorry for the delay, i was sick :(
you were right i messed up with the example config above, i have adjusted this to match my config

instance 1 -> having a config to connect with instance 2
instance 1 config
'hosts' => [ 'local' => [ 'name' => ucfirst(env('APP_ENV', 'local')), ], 'instance2' => [ 'name' => 'instance2', 'host' => 'http://instance2.ddev.site/log-viewer', ],

instance 2 is configured to use only api, which i can curl via console
instance 2 config
` 'enabled' => env('LOG_VIEWER_ENABLED', true),

'api_only' => env('LOG_VIEWER_API_ONLY', true),

'require_auth_in_production' => false,`

i hope it is clearer now.

using https it results in an error, as i am using a ddev project, which creates its cert itself via mkcert

Request failed with status code 500: cURL error 60: SSL: no alternative certificate subject name matches target host name 'toolero.ddev.site' (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://instance2.ddev.site/log-viewer/api/folders?direction=desc

when using http there is no feedback, no error, it just does not work. the ui blinks when using the dropdown, but the folder/files dont change, they stick to the local instance.

i tried to curl this as well via console, using http only, and still get a valid json response from logviewer

quite confident that everything is configured correctly, but either there is a missing error message or an error while using http.
the reason for http was to test it in a developer environment before rolling out to a staging environment with https, which has a real ssl cert, non self signed.

let me know if i can provide more information

@kantmn hey! So you can fetch http://instance2.ddev.site/log-viewer/api/folders?direction=desc via CURL, which is great. But what is the response? Does it contain an array of folders? I have seen some projects using middleware which modifies the responses and causes this array to become an object instead. Can you share what the endpoint returns?

@arukompas well yes i can, it looks like an array to me
i am not aware of any middleware modifying the response besides laravel base ones
[{"identifier":"b6f5f561","path":"\/var\/www\/html\/webroot\/storage\/logs","clean_path":"root","is_root":true,"earliest_timestamp":1728475859,"latest_timestamp":1730811043,"download_url":"https:\/\/instance2.ddev.site\/log-viewer\/api\/folders\/b6f5f561\/download","files":[{"type":{"value":"laravel","name":"Laravel"},"identifier":"8326adbb-laravel.log","sub_folder":"\/var\/www\/html\/webroot\/storage\/logs","sub_folder_identifier":"b6f5f561","path":"\/var\/www\/html\/webroot\/storage\/logs\/laravel.log","name":"laravel.log","size":736977,"size_in_mb":0.7028360366821289,"size_formatted":"719.70 KB","download_url":"https:\/\/instance2.ddev.site\/log-viewer\/api\/files\/8326adbb-laravel.log\/download","earliest_timestamp":1730811043,"latest_timestamp":1730811043,"can_download":true,"can_delete":true,"loading":false,"selected_for_deletion":false},{"type":{"value":"laravel","name":"Laravel"},"identifier":"fdc718c4-commands-2024-10-24.log","sub_folder":"\/var\/www\/html\/webroot\/storage\/logs","sub_folder_identifier":"b6f5f561","path":"\/var\/www\/html\/webroot\/storage\/logs\/commands-2024-10-24.log","name":"commands-2024-10-24.log","size":9513,"size_in_mb":0.009072303771972656,"size_formatted":"9.29 KB","download_url":"https:\/\/instance2.ddev.site\/log-viewer\/api\/files\/fdc718c4-commands-2024-10-24.log\/download","earliest_timestamp":1729785815,"latest_timestamp":1729785815,"can_download":true,"can_delete":true,"loading":false,"selected_for_deletion":false},{"type":{"value":"laravel","name":"Laravel"},"identifier":"39dd0945-commands-2024-10-21.log","sub_folder":"\/var\/www\/html\/webroot\/storage\/logs","sub_folder_identifier":"b6f5f561","path":"\/var\/www\/html\/webroot\/storage\/logs\/commands-2024-10-21.log","name":"commands-2024-10-21.log","size":622,"size_in_mb":0.0005931854248046875,"size_formatted":"622 bytes","download_url":"https:\/\/instance2.ddev.site\/log-viewer\/api\/files\/39dd0945-commands-2024-10-21.log\/download","earliest_timestamp":1729497364,"latest_timestamp":1729497364,"can_download":true,"can_delete":true,"loading":false,"selected_for_deletion":false},{"type":{"value":"laravel","name":"Laravel"},"identifier":"eb274c44-commands-2024-10-15.log","sub_folder":"\/var\/www\/html\/webroot\/storage\/logs","sub_folder_identifier":"b6f5f561","path":"\/var\/www\/html\/webroot\/storage\/logs\/commands-2024-10-15.log","name":"commands-2024-10-15.log","size":9312,"size_in_mb":0.008880615234375,"size_formatted":"9.09 KB","download_url":"https:\/\/instance2.ddev.site\/log-viewer\/api\/files\/eb274c44-commands-2024-10-15.log\/download","earliest_timestamp":1728986446,"latest_timestamp":1728986446,"can_download":true,"can_delete":true,"loading":false,"selected_for_deletion":false},{"type":{"value":"laravel","name":"Laravel"},"identifier":"5a47cc09-commands.log","sub_folder":"\/var\/www\/html\/webroot\/storage\/logs","sub_folder_identifier":"b6f5f561","path":"\/var\/www\/html\/webroot\/storage\/logs\/commands.log","name":"commands.log","size":105332,"size_in_mb":0.10045242309570312,"size_formatted":"102.86 KB","download_url":"https:\/\/instance2.ddev.site\/log-viewer\/api\/files\/5a47cc09-commands.log\/download","earliest_timestamp":1728475859,"latest_timestamp":1728475859,"can_download":true,"can_delete":true,"loading":false,"selected_for_deletion":false}],"can_download":true,"can_delete":true,"loading":false},{"identifier":"3f36f669","path":"\/var\/log\/nginx","clean_path":"\/var\/log\/nginx","is_root":false,"earliest_timestamp":1729092619,"latest_timestamp":1729092619,"download_url":"https:\/\/instance2.ddev.site\/log-viewer\/api\/folders\/3f36f669\/download","files":[{"type":{"value":"http_access","name":"HTTP Access"},"identifier":"51fab2a2-access.log","sub_folder":"\/var\/log\/nginx","sub_folder_identifier":"3f36f669","path":"\/var\/log\/nginx\/access.log","name":"access.log","size":0,"size_in_mb":0,"size_formatted":"0 bytes","download_url":"https:\/\/instance2.ddev.site\/log-viewer\/api\/files\/51fab2a2-access.log\/download","earliest_timestamp":1729092619,"latest_timestamp":1729092619,"can_download":true,"can_delete":true,"loading":false,"selected_for_deletion":false}],"can_download":true,"can_delete":true,"loading":false}]