Skip to content

Commit ddf7842

Browse files
committed
add server error log docs in README.md
1 parent 9d08c1b commit ddf7842

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ To get started with this project, follow the steps below.
7676

7777
### Configuration
7878

79+
#### Environment file
80+
7981
Create a **.env** file in the project root directory to store your environment variables. This is essential for configuring database connections and other settings.
8082

8183
Example .env file:
@@ -86,6 +88,24 @@ DB_PASS=my_password
8688
DB_NAME=db_php_restful_api
8789
```
8890

91+
#### Error Log
92+
93+
Create an **error.log** file in the logs directory to store all error logs that occur when the application runs.
94+
95+
```
96+
(root)
97+
├───config
98+
├───logs
99+
│ └───error.log # This is new file to log the error
100+
├───public
101+
├───src
102+
│ ├───controllers
103+
│ ├───models
104+
│ └───routes
105+
└───vendor
106+
```
107+
108+
89109
## Usage
90110

91111
After setting up the project, you can access the API endpoints using a tool like Postman or cURL. Below are some examples of how to use the endpoints:
@@ -117,6 +137,8 @@ curl -X DELETE http://localhost:8000/api/users/1
117137
```
118138

119139
## Error Handling
140+
141+
### API Response Code
120142
The API includes custom error handling to manage different scenarios, such as:
121143

122144
- 404 Not Found: When a user is not found.
@@ -125,5 +147,9 @@ The API includes custom error handling to manage different scenarios, such as:
125147

126148
All responses are returned in JSON format, providing a consistent structure for success and error messages.
127149

150+
### Error Log
151+
All server errors are logged to a file located at **logs/error.log**. This log file can be used to monitor your web application when it is live in production, helping to identify and troubleshoot issues effectively.
152+
153+
128154
## License
129155
This project is open-source and available under the MIT License. Feel free to modify and use it as a learning resource.

0 commit comments

Comments
 (0)