简体   繁体   English

AWS Ec2 中部署的 PHP API 的错误日志记录

[英]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.?我正在使用 AWS Ec2 实例来放置用 PHP 编写的 API。现在我已经使用 Log4PHP 进行错误日志记录。我想知道任何其他可用于 AWS Ec2 的内置错误日志记录工具。?

Ec2 has nothing to do with your application logs, it's something that totally depends on the application logic. Ec2 与您的应用程序日志无关,它完全取决于应用程序逻辑。 you application write logs and cloud service ship the logs The most common way of writing logs您的应用程序写入日志和云服务发送日志最常见的日志写入方式

  • Push logs to stdout/stderr将日志推送到 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.十二因素应用程序从不关心其 output stream 的路由或存储。 It should not attempt to write to or manage logfiles.它不应尝试写入或管理日志文件。 Instead, each running process writes its event stream, unbuffered, to stdout.相反,每个正在运行的进程将其事件 stream 无缓冲地写入标准输出。 During local development, the developer will view this stream in the foreground of their terminal to observe the app's behavior.在本地开发过程中,开发者会在终端的前台查看这个 stream 来观察应用的行为。

XI Logs: Treat logs as event streams XI Logs:将日志视为事件流

You can use PHP Monolog , which also suggested by AWS PHP logging article您可以使用PHP MonologAWS PHP 日志记录文章也建议使用

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. PHP Monolog 是一个符合标准的 PHP 库,使开发人员能够将日志发送到各种目标类型,包括数据库、文件、sockets 和不同的服务。 Although PHP Monolog predates the standards for PHP logging defined in PSR-3, it does implement the PSR-3 interface and standards.尽管 PHP Monolog 早于 PSR-3 中定义的 PHP 日志记录标准,但它确实实现了 PSR-3 接口和标准。

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.此外,rollbar 可以被视为评论中的建议,它独立于环境,您可以使用任何平台,但它不是免费的,您可以使用有限的日志 stream 进行试用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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