2025-09-01 18:47:30 +09:00
|
|
|
# 📊 Logging Configuration Guide
|
|
|
|
|
|
|
|
|
|
## Quick Log Level Changes
|
|
|
|
|
|
|
|
|
|
### Using the Script (Recommended)
|
2025-09-09 18:19:54 +09:00
|
|
|
|
2025-09-01 18:47:30 +09:00
|
|
|
```bash
|
|
|
|
|
# Check current level
|
|
|
|
|
./scripts/set-log-level.sh
|
|
|
|
|
|
|
|
|
|
# Set to minimal logging (production-like)
|
|
|
|
|
./scripts/set-log-level.sh warn
|
|
|
|
|
|
|
|
|
|
# Set to normal development logging
|
|
|
|
|
./scripts/set-log-level.sh info
|
|
|
|
|
|
|
|
|
|
# Set to detailed debugging
|
|
|
|
|
./scripts/set-log-level.sh debug
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Manual Configuration
|
2025-09-09 18:19:54 +09:00
|
|
|
|
2025-09-01 18:47:30 +09:00
|
|
|
Edit `.env` file:
|
2025-09-09 18:19:54 +09:00
|
|
|
|
2025-09-01 18:47:30 +09:00
|
|
|
```bash
|
|
|
|
|
LOG_LEVEL="info" # Change this value
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Log Levels Explained
|
|
|
|
|
|
2025-09-09 18:19:54 +09:00
|
|
|
| Level | Numeric | What You'll See | Best For |
|
|
|
|
|
| ------- | ------- | -------------------- | ------------------------- |
|
|
|
|
|
| `error` | 0 | Only critical errors | Production monitoring |
|
|
|
|
|
| `warn` | 1 | Warnings + errors | Quiet development |
|
|
|
|
|
| `info` | 2 | General operations | **Normal development** ⭐ |
|
|
|
|
|
| `debug` | 3 | Detailed debugging | Troubleshooting issues |
|
|
|
|
|
| `trace` | 4 | Very verbose tracing | Deep debugging |
|
2025-09-01 18:47:30 +09:00
|
|
|
|
|
|
|
|
## What's Been Optimized
|
|
|
|
|
|
|
|
|
|
### ✅ Reduced Noise
|
2025-09-09 18:19:54 +09:00
|
|
|
|
2025-09-01 18:47:30 +09:00
|
|
|
- **HTTP requests/responses**: Filtered out health checks, static assets
|
|
|
|
|
- **Request bodies**: Hidden by default (security + noise reduction)
|
|
|
|
|
- **Response bodies**: Hidden by default (reduces overwhelming output)
|
|
|
|
|
- **Session checks**: Frequent `/api/auth/session` calls ignored
|
|
|
|
|
|
|
|
|
|
### ✅ Cleaner Output
|
2025-09-09 18:19:54 +09:00
|
|
|
|
2025-09-01 18:47:30 +09:00
|
|
|
- **Pretty formatting**: Colored, timestamped logs in development
|
|
|
|
|
- **Message focus**: Emphasizes actual log messages over metadata
|
|
|
|
|
- **Structured data**: Still available but not overwhelming
|
|
|
|
|
|
|
|
|
|
### ✅ Security Enhanced
|
2025-09-09 18:19:54 +09:00
|
|
|
|
2025-09-01 18:47:30 +09:00
|
|
|
- **Sensitive data**: Automatically redacted (tokens, passwords, etc.)
|
|
|
|
|
- **Production ready**: No debug info exposed to customers
|
|
|
|
|
|
|
|
|
|
## Common Scenarios
|
|
|
|
|
|
|
|
|
|
### 🔇 Too Much Noise?
|
2025-09-09 18:19:54 +09:00
|
|
|
|
2025-09-01 18:47:30 +09:00
|
|
|
```bash
|
|
|
|
|
./scripts/set-log-level.sh warn
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 🐛 Debugging Issues?
|
2025-09-09 18:19:54 +09:00
|
|
|
|
2025-09-01 18:47:30 +09:00
|
|
|
```bash
|
|
|
|
|
./scripts/set-log-level.sh debug
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 🚀 Normal Development?
|
2025-09-09 18:19:54 +09:00
|
|
|
|
2025-09-01 18:47:30 +09:00
|
|
|
```bash
|
|
|
|
|
./scripts/set-log-level.sh info
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 📊 Production Monitoring?
|
2025-09-09 18:19:54 +09:00
|
|
|
|
2025-09-01 18:47:30 +09:00
|
|
|
```bash
|
|
|
|
|
./scripts/set-log-level.sh error
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Environment Variables
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
# Core logging
|
|
|
|
|
LOG_LEVEL="info" # Main log level
|
|
|
|
|
DISABLE_HTTP_LOGGING="false" # Set to "true" to disable HTTP logs entirely
|
|
|
|
|
|
|
|
|
|
# Application context
|
|
|
|
|
APP_NAME="customer-portal-bff" # Service name in logs
|
|
|
|
|
NODE_ENV="development" # Affects log formatting
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Restart Required
|
|
|
|
|
|
|
|
|
|
After changing log levels, restart your development server:
|
2025-09-09 18:19:54 +09:00
|
|
|
|
2025-09-01 18:47:30 +09:00
|
|
|
```bash
|
|
|
|
|
# Stop current server (Ctrl+C)
|
|
|
|
|
# Then restart
|
|
|
|
|
pnpm dev
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The new log level will take effect immediately.
|