title: Outputting Logs inside JSON Object with Winston and Winston-Daily-Rotate-File in Node.js
body: <p>I have the same problem and want the same result as in here: 
  <a href="https://stackoverflow.com/questions/53765625/outputting-logs-inside-json-object-with-winston-in-node-js">Outputting Logs inside JSON Object with Winston in Node.js</a></p>
  
  <p>But I use winston-daily-rotate-file and therefore the given answer/ solution does not work in my case. </p>
  
  <p>My logger looks like this: </p>
  
  <pre><code>const path = require('path');
  const { createLogger, format, transports, addColors, config } = require('winston');
  const winstonDailyRotateFile = require('winston-daily-rotate-file');
  const { combine, timestamp, json, colorize, label, printf, errors } = format;
  
  const CustomTransport = require('./customtransport')
  
  const customLevels = {
      levels: {
        error: 0,
        warn: 1,
        fileProcessed: 2,
        info: 3,
        debug: 4,
        silly: 5,
      },
      colors: {
          error: 'bold red',
          warn: 'bold yellow',
          fileProcessed: 'bold blue',
          info: 'bold cyan',
          debug: 'bold gray',
          silly: 'bold magenta'
      }
    };
  
  addColors(customLevels.colors);
  
  const consoleFormat = printf(({ level, message, label, stack }) =&gt; {
      const log = `${level}: [${label}] ${message}`;
      const errLog = `${log}\n${stack}`;
  
      return stack ? errLog : log;
  });
  
  module.exports = (module) =&gt; {
      const logger = createLogger({
          levels: customLevels.levels,
          transports: [
              new CustomTransport({
  
              }),
              new winstonDailyRotateFile({
                  format: combine(
                      errors({stack: true}),
                      timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
                      label({ label: path.basename(module.filename) }),
                      json(),
                  ),
                  dirname: './logs',
                  filename: 'sppa-%DATE%.log',
                  datePattern: 'YYYY-MM-DD',
                  zippedArchive: true,
                  maxSize: '20m',
                  maxFiles: '14d'
              })
          ]
      });
  
      // If we're not in production then log to the `console` 
      if (process.env.NODE_ENV !== 'production') {
          logger.add(new transports.Console({
              levels: customLevels.levels,
              level: 'silly',
              format: combine(
                  colorize(),
                  errors({stack: true}),
                  label({ label: path.basename(module.filename) }),
                  consoleFormat
              ),
          }));
      }
  
      return logger;
  }
  </code></pre>
  
  <p>Any help would be greatey appreciated!</p>