Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ PORT=3001
NODE_ENV=development
FRONTEND_URL=http://localhost:3000

# Logging
LOG_LEVEL=info

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/synchro

Expand Down
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist/
.env
.env.local
*.log
logs/
.DS_Store
coverage/
.nyc_output/
Expand Down
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"uuid": "^13.0.0",
"web-push": "^3.6.7",
"winston": "^3.14.0",
"winston-daily-rotate-file": "^5.0.0",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
18 changes: 16 additions & 2 deletions backend/src/config/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import winston from 'winston';
import DailyRotateFile from 'winston-daily-rotate-file';
import { requestContextStorage } from '../middleware/requestContext';

/**
Expand Down Expand Up @@ -27,8 +28,21 @@ const logger = winston.createLogger({
),
defaultMeta: { service: 'synchro-backend' },
transports: [
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'combined.log' }),
new DailyRotateFile({
filename: 'logs/error-%DATE%.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '10m',
maxFiles: '30d',
level: 'error',
}),
new DailyRotateFile({
filename: 'logs/combined-%DATE%.log',
datePattern: 'YYYY-MM-DD',
zippedArchive: true,
maxSize: '20m',
maxFiles: '14d',
}),
],
});

Expand Down