title: PM2 Log to a file with timestamps
body: <p>Currently, I have a NodeJS program which logs a lot of info to the console, as usual for many NodeJS programs. I was wondering if there is a way to have an output log for everything that is logged into the console with the file named after the timestamp it was created.</p>
  
  <p>I have been researching online for ways to save the logs and so far I have been able to find redirection, such as <code>node app.js &gt; logs/bot.log</code>. Although this works great, I needed pm2 so that any crashes restart yet I have not been able to find how to make pm2 have timestamped logs. I have found out that pm2 can have logs, but I've had trouble figuring out how to fix them for my needs.</p>
  
  <p>Not much code is needed to show this, but I just need all messages that are in the console to be logged to a file.</p>
  
  <pre><code>console.log("Sometimes, I dream about cheese...");
  </code></pre>
  
  <p>Ideally, I would like that and all other logs from before to be saved into a file called <code>bot.log</code> inside of the folder <code>logs</code> (<code>/logs/bot.log</code>).</p>
  
  <p>I'm hoping that I'll be able to receive help towards saving logs with the timestamps as their names of everything that has been printed to console, virtually making copies of the console that I can access at later dates for debugging etc. Thank you for any help!</p>