title: Nodejs - How to use morgan with debug
body: <p><a href="https://www.npmjs.com/package/morgan" rel="nofollow noreferrer">Morgan</a> outputs requests directly to the console.</p>
  
  <p>How can I redirect them to npm <a href="https://www.npmjs.com/package/debug" rel="nofollow noreferrer">debug</a> so that it follows the same format as the other stuff which is being logged?</p>
  
  <p>My <code>debug.js</code> config looks like the following:</p>
  
  <pre><code>import debug from 'debug';
  
  const LOG_PREFIX = 'api';
  
  const info = debug(`${LOG_PREFIX}:info`);
  const dev = debug(`${LOG_PREFIX}:dev`);
  const error = debug(`${LOG_PREFIX}:error`);
  
  export {
    info,
    dev,
    error,
  };
  </code></pre>
  
  <p>And I currently log other stuff like:</p>
  
  <pre><code>import { info } from './debug';
  
  info('App is up and running!');
  </code></pre>
  
  <p>My current morgan call is:</p>
  
  <pre><code>app.use(morgan('combined'));
  </code></pre>