title: How to enable GC logging for Hadoop YARN ResourceManager and ApplicationTimeline, while preventing log file overwrites and capping disk space usage
body: <p>We recently decided to enable GC logging for Hadoop YARN ResourceManager and ApplicationTimeline servers on a number of clusters (exact version varies) as a aid to looking into YARN-related memory and garbage collection problems.  While doing this, we want to avoid two problems we know might happen:</p>
  
  <ul>
  <li>overwriting of the log file when a YARN RM or AT server restarts for any reason</li>
  <li>the logs using too much disk space, leading to disks getting filled</li>
  </ul>
  
  <p>When Java GC logging starts for a process it seems to replace the content of any file that has the same name. This means that unless you are careful, you will lose the GC logging, perhaps when you are more likely to need it.</p>
  
  <p>If you keep the cluster running long enough, log files will fill up disk unless managed.  Even if GC logging is not currently voluminous we want to manage the risk of an unusual situation arising that causes the logging rate to spike up.</p>