winston.config.js 958 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict'
  2. import winston from 'winston'
  3. // Logger configuration
  4. export const logger = winston.createLogger({
  5. level: 'info',
  6. format: winston.format.json(),
  7. transports: [
  8. new winston.transports.File({ filename: 'logs/server.combined.log' }),
  9. new winston.transports.File({ filename: 'logs/server.error.log', level: 'error' }),
  10. new winston.transports.Console({
  11. level: 'debug',
  12. handleExceptions: true,
  13. format: winston.format.json()
  14. })
  15. ],
  16. exitOnError: false
  17. })
  18. // Database logger configuration
  19. export const dbLogger = winston.createLogger({
  20. level: 'info',
  21. format: winston.format.json(),
  22. transports: [
  23. new winston.transports.File({ filename: 'logs/db.log' }),
  24. new winston.transports.File({ filename: 'logs/db.error.log', level: 'error' }),
  25. new winston.transports.Console({
  26. level: 'debug',
  27. handleExceptions: true,
  28. format: winston.format.json()
  29. })
  30. ],
  31. exitOnError: false
  32. })