grkamil / laravel-telegram-logging

Send logs to Telegram chat via Telegram bot
MIT License
148 stars 36 forks source link

Logs not working in production #1

Closed anasbud closed 5 years ago

anasbud commented 5 years ago

I'm sure my problem doesn't come from this package but I ran out of solution.

When I log a simple string Log::info('test'); it works perfectly in local.

But in production server (VPS), it does not. I don't know why. I checked everything. The logs are being written correctly in the logs. But when I set the LOG_CHANNEL to telegram, nothing happens. I tried putting "telegram" in the stack array. Nothing. Any idea ?

grkamil commented 5 years ago

Did you configure .env in the production? TELEGRAM_LOGGER_BOT_TOKEN= TELEGRAM_LOGGER_CHAT_ID=

First of all, check that chat_id and bot_token has been set properly. Check that you have written to the chat with bot before using (because telegram bots cannot start chat with you by themselves)

Also, if nothing happens it probably some problems with sending message to the telegram from your VPS. (e.g telegram can be blocked from your VPS location).

anasbud commented 5 years ago

it's perfectly working from my local computer. So it's not related to the env data.

And lastly I made a file_get_contents in php artisan tinker and it's working fine also. Really I'm running out of ideas.

anasbud commented 5 years ago

Ok, I found the issue.

I made a dump and found out that $this->botToken and $this->chatId were null why ? Because I cache my config (php artisan config:cache).

When I cleared my cache (php artisan config:clear), I worked.

See this post for more information: https://laracasts.com/discuss/channels/laravel/configcache-makes-variables-in-env-null

grkamil commented 5 years ago

Great, thx. I will fix that.