简体   繁体   中英

Error logging for PHP API deployed in AWS Ec2

I am using AWS Ec2 instance to place my API written in PHP.Right now i have used Log4PHP for error logging.I want to know any other built in Error Logging facilities available for AWS Ec2.?

Ec2 has nothing to do with your application logs, it's something that totally depends on the application logic. you application write logs and cloud service ship the logs The most common way of writing logs

  • Push logs to stdout/stderr
  • Write logs to log file

The first approach is recommended approach in cloud environment plus this is also base on The twelve-factor app

A twelve-factor app never concerns itself with routing or storage of its output stream. It should not attempt to write to or manage logfiles. Instead, each running process writes its event stream, unbuffered, to stdout. During local development, the developer will view this stream in the foreground of their terminal to observe the app's behavior.

XI Logs: Treat logs as event streams

You can use PHP Monolog , which also suggested by AWS PHP logging article

PHP Monolog is a standards-compliant PHP library that enables developers to send logs to various destination types including, databases, files, sockets, and different services. Although PHP Monolog predates the standards for PHP logging defined in PSR-3, it does implement the PSR-3 interface and standards.

Here is the details article to check about integration of the library with different framework.

在此处输入图像描述

Also, rollbar can be considered as suggested in the comment, its environment independent and you use this any platform but its not free and you can trial with limited log stream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM