winston.config.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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.simple()
  14. })
  15. ],
  16. exitOnError: false
  17. })
  18. // WebSocket logger configuration
  19. export const wsLogger = winston.createLogger({
  20. level: 'info',
  21. format: winston.format.json(),
  22. transports: [
  23. new winston.transports.File({ filename: 'logs/ws.log' }),
  24. new winston.transports.File({ filename: 'logs/ws.error.log', level: 'error' }),
  25. new winston.transports.Console({
  26. level: 'debug',
  27. handleExceptions: true,
  28. format: winston.format.simple()
  29. })
  30. ],
  31. exitOnError: false
  32. })
  33. // Database logger configuration
  34. export const dbLogger = winston.createLogger({
  35. level: 'info',
  36. format: winston.format.json(),
  37. transports: [
  38. new winston.transports.File({ filename: 'logs/db.log' }),
  39. new winston.transports.File({ filename: 'logs/db.error.log', level: 'error' }),
  40. new winston.transports.Console({
  41. level: 'debug',
  42. handleExceptions: true,
  43. format: winston.format.simple()
  44. })
  45. ],
  46. exitOnError: false
  47. })