Question

How to get runtime logs with PHP on App Platform with/without log forwarding (Logtail)?

I’ve tried various ways of getting “Runtime Logs” to output anything app-related from my PHP project, for example:

error_log("This is a runtime error log message");
fwrite(STDOUT, "This is a runtime log message\n");

But I’m not getting this anywhere in Runtime Logs whenever I invoke my function. I also set up Log Forward with Logtail but nothing appears there.

I’m wondering what I’m doing wrong?

Basically want I want, is to log certain events as my function runs, to help in debugging etc.

Thanks.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
September 3, 2024

Hey!

I’ve just tested this with this simple PHP app here:

https://github.com/digitalocean/sample-php/

I’ve forked that project and added a error_log line here:

https://github.com/bobbyiliev/sample-php/blob/main/index.php#L16

And the error_log("This is a runtime error log message"); worked for me:

Is your project open-source by any chance? If so can you share a link here so I can take a quick look?

If the project is not open-source, feel free to share more details on your exact setup or framework that you are using.

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
Animation showing a Droplet being created in the DigitalOcean Cloud console