Rails logs to betterstack

azdalminaHOBBY

a year ago

I'm trying to send my Rails App's logs to betterstack, but on Railway is not working.
I followed the install process as documentation explain (https://github.com/logtail/logtail-ruby-rails), its working on my machine, but not on Railway. Checking Railway Logs documentation, I see a normalization process that Railway make: https://docs.railway.app/guides/logs#normalization-strategy

Could this normalization process impact the betterstack logger?
Does someone integrate Rails with betterstack on Railway?

Solved

6 Replies

a year ago

Railways logging system has nothing to do with using a logging gem.

on Railway is not working

I'm sorry but that's not particularly helpful, what errors are you getting?


azdalminaHOBBY

a year ago

I'm not getting any errors, just the logs are not sending to BetterStack. To be honest I'm getting one log on BetterStack, the shutdown of sidekiq. (attached file)
Any other rails log are not sending to BetterStack.

I try to run locally with Railway envs (railway shell) and in this case it works as expected.
I don't know that are causing this weird behavior.

Attachments


azdalminaHOBBY

a year ago

After deploying my Rails app to both DigitalOcean and Vultr, I confirm them are sending logs to BetterStack without any problem.
So it seems that there's an issue with how Railway handles logs, as I'm unable to send them to BetterStack through Railway. While I haven't tested other log services yet, it's evident that Railway isn't compatible with BetterStack.


a year ago

The gem you linked is purely in-code, it has no relation to the platform it runs out.

it seems that there's an issue with how Railway handles logs

it's evident that Railway isn't compatible with BetterStack

These statements are woefully inaccurate, your in-code logging has nothing to do with the platform.

Working elsewhere is evidence that you have something misconfigured somewhere in your Railway deployment. Please read over BetterStack's documentation and make sure you have all the correct service variables.

For what its worth, I have done logging to BetterStack and even Axiom from my app deployed to Railway without issue.


azdalminaHOBBY

a year ago

Thank you so much for your attention brody!
Apologies for any confusion caused by my previous explanation.

The problem is about the ENV RAILS_LOG_TO_STDOUT. This conditional is returning true on production, even without set the ENV: if ENV['RAILS_LOG_TO_STDOUT'].present?

The code inside this conditional is redirecting the logs to STDOUT, of course it will not send to BetterStack. But this ENV is not set on services variables, not being set in any step of deployment. I couldn`t identify why this conditional is returning true without the ENV being set, but I change the conditional and the logs are working as expected.

PS: On other platforms (DO and Vultr) I didn't need to chance this conditional to logs works.


Status changed to Solved railway[bot] 12 months ago


a year ago

Nixpacks sets that variable by default.