changeset 9727:f944761a3ce3

8145092: Use Unified Logging for the GC logging Summary: JEP-271. VM changes contributed by brutisso, test changes contributed by david. Reviewed-by: sjohanss, david, brutisso Contributed-by: bengt.rutisson@oracle.com, david.lindholm@oralce.com
author brutisso
date Thu, 10 Dec 2015 14:57:55 +0100
parents 2b4c71d036af
children 0e4622635d09
files src/os/windows/vm/os_windows.cpp src/share/vm/Xusage.txt src/share/vm/gc/cms/allocationStats.hpp src/share/vm/gc/cms/compactibleFreeListSpace.cpp src/share/vm/gc/cms/compactibleFreeListSpace.hpp src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp src/share/vm/gc/cms/parNewGeneration.cpp src/share/vm/gc/cms/parOopClosures.inline.hpp src/share/vm/gc/cms/promotionInfo.hpp src/share/vm/gc/cms/vmCMSOperations.cpp src/share/vm/gc/g1/collectionSetChooser.cpp src/share/vm/gc/g1/concurrentG1RefineThread.cpp src/share/vm/gc/g1/concurrentMark.cpp src/share/vm/gc/g1/concurrentMark.hpp src/share/vm/gc/g1/concurrentMarkThread.cpp src/share/vm/gc/g1/concurrentMarkThread.hpp src/share/vm/gc/g1/g1BlockOffsetTable.cpp src/share/vm/gc/g1/g1CollectedHeap.cpp src/share/vm/gc/g1/g1CollectedHeap.hpp src/share/vm/gc/g1/g1CollectorPolicy.cpp src/share/vm/gc/g1/g1CollectorPolicy.hpp src/share/vm/gc/g1/g1ErgoVerbose.cpp src/share/vm/gc/g1/g1ErgoVerbose.hpp src/share/vm/gc/g1/g1EvacStats.cpp src/share/vm/gc/g1/g1GCPhaseTimes.cpp src/share/vm/gc/g1/g1GCPhaseTimes.hpp src/share/vm/gc/g1/g1HRPrinter.cpp src/share/vm/gc/g1/g1HRPrinter.hpp src/share/vm/gc/g1/g1IHOPControl.cpp src/share/vm/gc/g1/g1Log.cpp src/share/vm/gc/g1/g1Log.hpp src/share/vm/gc/g1/g1MarkSweep.cpp src/share/vm/gc/g1/g1RemSet.cpp src/share/vm/gc/g1/g1RemSet.hpp src/share/vm/gc/g1/g1RemSetSummary.cpp src/share/vm/gc/g1/g1RemSetSummary.hpp src/share/vm/gc/g1/g1SATBCardTableModRefBS.cpp src/share/vm/gc/g1/g1StringDedupQueue.cpp src/share/vm/gc/g1/g1StringDedupQueue.hpp src/share/vm/gc/g1/g1StringDedupStat.cpp src/share/vm/gc/g1/g1StringDedupStat.hpp src/share/vm/gc/g1/g1StringDedupTable.cpp src/share/vm/gc/g1/g1StringDedupTable.hpp src/share/vm/gc/g1/g1StringDedupThread.cpp src/share/vm/gc/g1/g1StringDedupThread.hpp src/share/vm/gc/g1/g1_globals.hpp src/share/vm/gc/g1/heapRegion.cpp src/share/vm/gc/g1/heapRegionRemSet.cpp src/share/vm/gc/g1/heapRegionRemSet.hpp src/share/vm/gc/g1/heapRegionSet.cpp src/share/vm/gc/g1/heapRegionSet.hpp src/share/vm/gc/g1/satbMarkQueue.cpp src/share/vm/gc/g1/survRateGroup.cpp src/share/vm/gc/g1/vm_operations_g1.cpp src/share/vm/gc/g1/workerDataArray.cpp src/share/vm/gc/g1/workerDataArray.hpp src/share/vm/gc/g1/workerDataArray.inline.hpp src/share/vm/gc/g1/youngList.cpp src/share/vm/gc/parallel/adjoiningGenerations.cpp src/share/vm/gc/parallel/asPSOldGen.cpp src/share/vm/gc/parallel/asPSYoungGen.cpp src/share/vm/gc/parallel/cardTableExtension.cpp src/share/vm/gc/parallel/gcTaskManager.cpp src/share/vm/gc/parallel/gcTaskThread.cpp src/share/vm/gc/parallel/parallelScavengeHeap.cpp src/share/vm/gc/parallel/parallelScavengeHeap.hpp src/share/vm/gc/parallel/pcTasks.cpp src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp src/share/vm/gc/parallel/psAdaptiveSizePolicy.hpp src/share/vm/gc/parallel/psCompactionManager.cpp src/share/vm/gc/parallel/psMarkSweep.cpp src/share/vm/gc/parallel/psOldGen.cpp src/share/vm/gc/parallel/psParallelCompact.cpp src/share/vm/gc/parallel/psParallelCompact.hpp src/share/vm/gc/parallel/psPromotionManager.cpp src/share/vm/gc/parallel/psPromotionManager.hpp src/share/vm/gc/parallel/psPromotionManager.inline.hpp src/share/vm/gc/parallel/psScavenge.cpp src/share/vm/gc/parallel/psScavenge.inline.hpp src/share/vm/gc/parallel/psVirtualspace.cpp src/share/vm/gc/parallel/psVirtualspace.hpp src/share/vm/gc/parallel/psYoungGen.cpp src/share/vm/gc/serial/defNewGeneration.cpp src/share/vm/gc/serial/defNewGeneration.hpp src/share/vm/gc/serial/genMarkSweep.cpp src/share/vm/gc/serial/markSweep.cpp src/share/vm/gc/serial/tenuredGeneration.cpp src/share/vm/gc/shared/adaptiveSizePolicy.cpp src/share/vm/gc/shared/adaptiveSizePolicy.hpp src/share/vm/gc/shared/ageTable.cpp src/share/vm/gc/shared/blockOffsetTable.cpp src/share/vm/gc/shared/cardGeneration.cpp src/share/vm/gc/shared/cardTableModRefBS.cpp src/share/vm/gc/shared/collectedHeap.cpp src/share/vm/gc/shared/collectedHeap.hpp src/share/vm/gc/shared/collectorPolicy.cpp src/share/vm/gc/shared/gcCause.hpp src/share/vm/gc/shared/gcId.cpp src/share/vm/gc/shared/gcId.hpp src/share/vm/gc/shared/gcLocker.cpp src/share/vm/gc/shared/gcLocker.hpp src/share/vm/gc/shared/gcTraceTime.cpp src/share/vm/gc/shared/gcTraceTime.hpp src/share/vm/gc/shared/gcTraceTime.inline.hpp src/share/vm/gc/shared/genCollectedHeap.cpp src/share/vm/gc/shared/genCollectedHeap.hpp src/share/vm/gc/shared/generation.cpp src/share/vm/gc/shared/generation.hpp src/share/vm/gc/shared/plab.cpp src/share/vm/gc/shared/plab.hpp src/share/vm/gc/shared/referenceProcessor.cpp src/share/vm/gc/shared/referenceProcessor.hpp src/share/vm/gc/shared/space.hpp src/share/vm/gc/shared/spaceDecorator.cpp src/share/vm/gc/shared/taskqueue.cpp src/share/vm/gc/shared/threadLocalAllocBuffer.cpp src/share/vm/gc/shared/threadLocalAllocBuffer.inline.hpp src/share/vm/gc/shared/vmGCOperations.cpp src/share/vm/logging/logPrefix.hpp src/share/vm/logging/logTag.hpp src/share/vm/memory/binaryTreeDictionary.cpp src/share/vm/memory/binaryTreeDictionary.hpp src/share/vm/memory/filemap.cpp src/share/vm/memory/freeBlockDictionary.hpp src/share/vm/memory/metaspace.cpp src/share/vm/memory/universe.cpp src/share/vm/memory/universe.hpp src/share/vm/oops/instanceKlass.cpp src/share/vm/oops/instanceRefKlass.inline.hpp src/share/vm/prims/jni.cpp src/share/vm/prims/jvmtiEnv.cpp src/share/vm/prims/whitebox.cpp src/share/vm/runtime/arguments.cpp src/share/vm/runtime/arguments.hpp src/share/vm/runtime/globals.hpp src/share/vm/runtime/interfaceSupport.cpp src/share/vm/runtime/java.cpp src/share/vm/runtime/jniHandles.cpp src/share/vm/runtime/os.cpp src/share/vm/runtime/safepoint.cpp src/share/vm/runtime/timer.cpp src/share/vm/runtime/vmThread.cpp src/share/vm/runtime/vm_operations.cpp src/share/vm/runtime/vm_operations.hpp src/share/vm/services/diagnosticCommand.cpp src/share/vm/services/diagnosticCommand.hpp src/share/vm/services/memoryService.cpp src/share/vm/services/memoryService.hpp src/share/vm/services/runtimeService.cpp src/share/vm/utilities/debug.cpp src/share/vm/utilities/numberSeq.cpp src/share/vm/utilities/ostream.cpp src/share/vm/utilities/ostream.hpp test/TEST.groups test/gc/6941923/Test6941923.java test/gc/7072527/TestFullGCCount.java test/gc/TestDisableExplicitGC.java test/gc/TestGCLogRotationViaJcmd.java test/gc/TestVerifyDuringStartup.java test/gc/TestVerifySilently.java test/gc/arguments/TestTargetSurvivorRatioFlag.java test/gc/arguments/TestUnrecognizedVMOptionsHandling.java test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java test/gc/class_unloading/TestCMSClassUnloadingEnabledHWM.java test/gc/class_unloading/TestG1ClassUnloadingHWM.java test/gc/cms/DisableResizePLAB.java test/gc/cms/TestCMSScavengeBeforeRemark.java test/gc/ergonomics/TestDynamicNumberOfGCThreads.java test/gc/g1/TestEagerReclaimHumongousRegions.java test/gc/g1/TestEagerReclaimHumongousRegionsClearMarkBits.java test/gc/g1/TestEagerReclaimHumongousRegionsWithRefs.java test/gc/g1/TestG1TraceEagerReclaimHumongousObjects.java test/gc/g1/TestGCLogMessages.java test/gc/g1/TestHumongousAllocInitialMark.java test/gc/g1/TestHumongousAllocNearlyFullRegion.java test/gc/g1/TestNoEagerReclaimOfHumongousRegions.java test/gc/g1/TestPLABOutput.java test/gc/g1/TestPrintGCDetails.java test/gc/g1/TestPrintRegionRememberedSetInfo.java test/gc/g1/TestRemsetLogging.java test/gc/g1/TestRemsetLoggingPerRegion.java test/gc/g1/TestRemsetLoggingThreads.java test/gc/g1/TestRemsetLoggingTools.java test/gc/g1/TestShrinkAuxiliaryData.java test/gc/g1/TestStringDeduplicationTools.java test/gc/g1/TestStringSymbolTableStats.java test/gc/g1/TestSummarizeRSetStats.java test/gc/g1/TestSummarizeRSetStatsPerRegion.java test/gc/g1/TestSummarizeRSetStatsThreads.java test/gc/g1/TestSummarizeRSetStatsTools.java test/gc/g1/mixedgc/TestLogging.java test/gc/logging/TestGCId.java test/gc/logging/TestPrintReferences.java test/gc/serial/HeapChangeLogging.java test/gc/whitebox/TestWBGC.java test/runtime/7158988/FieldMonitor.java test/runtime/CommandLine/PrintGCApplicationConcurrentTime.java test/runtime/CommandLine/TestVMOptions.java test/runtime/CompressedOops/CompressedClassPointers.java test/runtime/CompressedOops/CompressedClassSpaceSize.java test/serviceability/dcmd/gc/RunGCTest.java test/serviceability/dcmd/vm/FlagsTest.java test/serviceability/logging/TestLogRotation.java
diffstat 204 files changed, 3726 insertions(+), 6542 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/windows/vm/os_windows.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/os/windows/vm/os_windows.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -5719,7 +5719,7 @@
 void TestReserveMemorySpecial_test() {
   if (!UseLargePages) {
     if (VerboseInternalVMTests) {
-      gclog_or_tty->print("Skipping test because large pages are disabled");
+      tty->print("Skipping test because large pages are disabled");
     }
     return;
   }
@@ -5735,7 +5735,7 @@
   char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false);
   if (result == NULL) {
     if (VerboseInternalVMTests) {
-      gclog_or_tty->print("Failed to allocate control block with size " SIZE_FORMAT ". Skipping remainder of test.",
+      tty->print("Failed to allocate control block with size " SIZE_FORMAT ". Skipping remainder of test.",
                           large_allocation_size);
     }
   } else {
@@ -5748,7 +5748,7 @@
     char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false);
     if (actual_location == NULL) {
       if (VerboseInternalVMTests) {
-        gclog_or_tty->print("Failed to allocate any memory at " PTR_FORMAT " size " SIZE_FORMAT ". Skipping remainder of test.",
+        tty->print("Failed to allocate any memory at " PTR_FORMAT " size " SIZE_FORMAT ". Skipping remainder of test.",
                             expected_location, large_allocation_size);
       }
     } else {
--- a/src/share/vm/Xusage.txt	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/Xusage.txt	Thu Dec 10 14:57:55 2015 +0100
@@ -8,7 +8,6 @@
                       prepend in front of bootstrap class path
     -Xnoclassgc       disable class garbage collection
     -Xlog:<opts>      control JVM logging, use -Xlog:help for details
-    -Xloggc:<file>    log GC status to a file with time stamps
     -Xbatch           disable background compilation
     -Xms<size>        set initial Java heap size
     -Xmx<size>        set maximum Java heap size
--- a/src/share/vm/gc/cms/allocationStats.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/cms/allocationStats.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -26,6 +26,7 @@
 #define SHARE_VM_GC_CMS_ALLOCATIONSTATS_HPP
 
 #include "gc/shared/gcUtil.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.hpp"
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/macros.hpp"
@@ -119,11 +120,9 @@
       ssize_t old_desired = _desired;
       float delta_ise = (CMSExtrapolateSweep ? intra_sweep_estimate : 0.0);
       _desired = (ssize_t)(new_rate * (inter_sweep_estimate + delta_ise));
-      if (PrintFLSStatistics > 1) {
-        gclog_or_tty->print_cr("demand: " SSIZE_FORMAT ", old_rate: %f, current_rate: %f, "
-                               "new_rate: %f, old_desired: " SSIZE_FORMAT ", new_desired: " SSIZE_FORMAT,
-                                demand, old_rate, rate, new_rate, old_desired, _desired);
-      }
+      log_trace(gc, freelist)("demand: " SSIZE_FORMAT ", old_rate: %f, current_rate: %f, "
+                              "new_rate: %f, old_desired: " SSIZE_FORMAT ", new_desired: " SSIZE_FORMAT,
+                              demand, old_rate, rate, new_rate, old_desired, _desired);
     }
   }
 
--- a/src/share/vm/gc/cms/compactibleFreeListSpace.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/cms/compactibleFreeListSpace.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -400,17 +400,16 @@
 
 void CompactibleFreeListSpace::print_indexed_free_lists(outputStream* st)
 const {
-  reportIndexedFreeListStatistics();
-  gclog_or_tty->print_cr("Layout of Indexed Freelists");
-  gclog_or_tty->print_cr("---------------------------");
+  reportIndexedFreeListStatistics(st);
+  st->print_cr("Layout of Indexed Freelists");
+  st->print_cr("---------------------------");
   AdaptiveFreeList<FreeChunk>::print_labels_on(st, "size");
   for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
-    _indexedFreeList[i].print_on(gclog_or_tty);
-    for (FreeChunk* fc = _indexedFreeList[i].head(); fc != NULL;
-         fc = fc->next()) {
-      gclog_or_tty->print_cr("\t[" PTR_FORMAT "," PTR_FORMAT ")  %s",
-                          p2i(fc), p2i((HeapWord*)fc + i),
-                          fc->cantCoalesce() ? "\t CC" : "");
+    _indexedFreeList[i].print_on(st);
+    for (FreeChunk* fc = _indexedFreeList[i].head(); fc != NULL; fc = fc->next()) {
+      st->print_cr("\t[" PTR_FORMAT "," PTR_FORMAT ")  %s",
+                   p2i(fc), p2i((HeapWord*)fc + i),
+                   fc->cantCoalesce() ? "\t CC" : "");
     }
   }
 }
@@ -422,7 +421,7 @@
 
 void CompactibleFreeListSpace::print_dictionary_free_lists(outputStream* st)
 const {
-  _dictionary->report_statistics();
+  _dictionary->report_statistics(st);
   st->print_cr("Layout of Freelists in Tree");
   st->print_cr("---------------------------");
   _dictionary->print_free_lists(st);
@@ -472,54 +471,58 @@
   return sz;
 }
 
-void CompactibleFreeListSpace::dump_at_safepoint_with_locks(CMSCollector* c,
-  outputStream* st) {
-  st->print_cr("\n=========================");
+void CompactibleFreeListSpace::dump_at_safepoint_with_locks(CMSCollector* c, outputStream* st) {
+  st->print_cr("=========================");
   st->print_cr("Block layout in CMS Heap:");
   st->print_cr("=========================");
   BlkPrintingClosure  bpcl(c, this, c->markBitMap(), st);
   blk_iterate(&bpcl);
 
-  st->print_cr("\n=======================================");
+  st->print_cr("=======================================");
   st->print_cr("Order & Layout of Promotion Info Blocks");
   st->print_cr("=======================================");
   print_promo_info_blocks(st);
 
-  st->print_cr("\n===========================");
+  st->print_cr("===========================");
   st->print_cr("Order of Indexed Free Lists");
   st->print_cr("=========================");
   print_indexed_free_lists(st);
 
-  st->print_cr("\n=================================");
+  st->print_cr("=================================");
   st->print_cr("Order of Free Lists in Dictionary");
   st->print_cr("=================================");
   print_dictionary_free_lists(st);
 }
 
 
-void CompactibleFreeListSpace::reportFreeListStatistics() const {
+void CompactibleFreeListSpace::reportFreeListStatistics(const char* title) const {
   assert_lock_strong(&_freelistLock);
-  assert(PrintFLSStatistics != 0, "Reporting error");
-  _dictionary->report_statistics();
-  if (PrintFLSStatistics > 1) {
-    reportIndexedFreeListStatistics();
+  LogHandle(gc, freelist, stats) log;
+  if (!log.is_debug()) {
+    return;
+  }
+  log.debug("%s", title);
+  _dictionary->report_statistics(log.debug_stream());
+  if (log.is_trace()) {
+    ResourceMark rm;
+    reportIndexedFreeListStatistics(log.trace_stream());
     size_t total_size = totalSizeInIndexedFreeLists() +
                        _dictionary->total_chunk_size(DEBUG_ONLY(freelistLock()));
-    gclog_or_tty->print(" free=" SIZE_FORMAT " frag=%1.4f\n", total_size, flsFrag());
+    log.trace(" free=" SIZE_FORMAT " frag=%1.4f", total_size, flsFrag());
   }
 }
 
-void CompactibleFreeListSpace::reportIndexedFreeListStatistics() const {
+void CompactibleFreeListSpace::reportIndexedFreeListStatistics(outputStream* st) const {
   assert_lock_strong(&_freelistLock);
-  gclog_or_tty->print("Statistics for IndexedFreeLists:\n"
-                      "--------------------------------\n");
+  st->print_cr("Statistics for IndexedFreeLists:");
+  st->print_cr("--------------------------------");
   size_t total_size = totalSizeInIndexedFreeLists();
-  size_t   free_blocks = numFreeBlocksInIndexedFreeLists();
-  gclog_or_tty->print("Total Free Space: " SIZE_FORMAT "\n", total_size);
-  gclog_or_tty->print("Max   Chunk Size: " SIZE_FORMAT "\n", maxChunkSizeInIndexedFreeLists());
-  gclog_or_tty->print("Number of Blocks: " SIZE_FORMAT "\n", free_blocks);
+  size_t free_blocks = numFreeBlocksInIndexedFreeLists();
+  st->print_cr("Total Free Space: " SIZE_FORMAT, total_size);
+  st->print_cr("Max   Chunk Size: " SIZE_FORMAT, maxChunkSizeInIndexedFreeLists());
+  st->print_cr("Number of Blocks: " SIZE_FORMAT, free_blocks);
   if (free_blocks != 0) {
-    gclog_or_tty->print("Av.  Block  Size: " SIZE_FORMAT "\n", total_size/free_blocks);
+    st->print_cr("Av.  Block  Size: " SIZE_FORMAT, total_size/free_blocks);
   }
 }
 
@@ -1824,10 +1827,7 @@
 void
 CompactibleFreeListSpace::gc_prologue() {
   assert_locked();
-  if (PrintFLSStatistics != 0) {
-    gclog_or_tty->print("Before GC:\n");
-    reportFreeListStatistics();
-  }
+  reportFreeListStatistics("Before GC:");
   refillLinearAllocBlocksIfNeeded();
 }
 
@@ -1837,11 +1837,7 @@
   assert(_promoInfo.noPromotions(), "_promoInfo inconsistency");
   _promoInfo.stopTrackingPromotions();
   repairLinearAllocationBlocks();
-  // Print Space's stats
-  if (PrintFLSStatistics != 0) {
-    gclog_or_tty->print("After GC:\n");
-    reportFreeListStatistics();
-  }
+  reportFreeListStatistics("After GC:");
 }
 
 // Iteration support, mostly delegated from a CMS generation
@@ -2014,9 +2010,7 @@
   size_t i;
   for (i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
     AdaptiveFreeList<FreeChunk>* fl    = &_indexedFreeList[i];
-    if (PrintFLSStatistics > 1) {
-      gclog_or_tty->print("size[" SIZE_FORMAT "] : ", i);
-    }
+    log_trace(gc, freelist)("size[" SIZE_FORMAT "] : ", i);
     fl->compute_desired(inter_sweep_current, inter_sweep_estimate, intra_sweep_estimate);
     fl->set_coal_desired((ssize_t)((double)fl->desired() * CMSSmallCoalSurplusPercent));
     fl->set_before_sweep(fl->count());
@@ -2065,16 +2059,10 @@
 }
 
 void CompactibleFreeListSpace::endSweepFLCensus(size_t sweep_count) {
-  if (PrintFLSStatistics > 0) {
-    HeapWord* largestAddr = (HeapWord*) dictionary()->find_largest_dict();
-    gclog_or_tty->print_cr("CMS: Large block " PTR_FORMAT,
-                           p2i(largestAddr));
-  }
+  log_debug(gc, freelist)("CMS: Large block " PTR_FORMAT, p2i(dictionary()->find_largest_dict()));
   setFLSurplus();
   setFLHints();
-  if (PrintGC && PrintFLSCensus > 0) {
-    printFLCensus(sweep_count);
-  }
+  printFLCensus(sweep_count);
   clearFLCensus();
   assert_locked();
   _dictionary->end_sweep_dict_census(CMSLargeSplitSurplusPercent);
@@ -2213,14 +2201,15 @@
       }
     }
     if (res == 0) {
-      gclog_or_tty->print_cr("Livelock: no rank reduction!");
-      gclog_or_tty->print_cr(
-        " Current:  addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n"
-        " Previous: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n",
+      LogHandle(gc, verify) log;
+      log.info("Livelock: no rank reduction!");
+      log.info(" Current:  addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n"
+               " Previous: addr = " PTR_FORMAT ", size = " SIZE_FORMAT ", obj = %s, live = %s \n",
         p2i(addr),       res,        was_obj      ?"true":"false", was_live      ?"true":"false",
         p2i(_last_addr), _last_size, _last_was_obj?"true":"false", _last_was_live?"true":"false");
-      _sp->print_on(gclog_or_tty);
-      guarantee(false, "Seppuku!");
+      ResourceMark rm;
+      _sp->print_on(log.info_stream());
+      guarantee(false, "Verification failed.");
     }
     _last_addr = addr;
     _last_size = res;
@@ -2386,17 +2375,23 @@
 
 void CompactibleFreeListSpace::printFLCensus(size_t sweep_count) const {
   assert_lock_strong(&_freelistLock);
+  LogHandle(gc, freelist, census) log;
+  if (!log.is_debug()) {
+    return;
+  }
   AdaptiveFreeList<FreeChunk> total;
-  gclog_or_tty->print("end sweep# " SIZE_FORMAT "\n", sweep_count);
-  AdaptiveFreeList<FreeChunk>::print_labels_on(gclog_or_tty, "size");
+  log.debug("end sweep# " SIZE_FORMAT, sweep_count);
+  ResourceMark rm;
+  outputStream* out = log.debug_stream();
+  AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
   size_t total_free = 0;
   for (size_t i = IndexSetStart; i < IndexSetSize; i += IndexSetStride) {
     const AdaptiveFreeList<FreeChunk> *fl = &_indexedFreeList[i];
     total_free += fl->count() * fl->size();
     if (i % (40*IndexSetStride) == 0) {
-      AdaptiveFreeList<FreeChunk>::print_labels_on(gclog_or_tty, "size");
+      AdaptiveFreeList<FreeChunk>::print_labels_on(out, "size");
     }
-    fl->print_on(gclog_or_tty);
+    fl->print_on(out);
     total.set_bfr_surp(    total.bfr_surp()     + fl->bfr_surp()    );
     total.set_surplus(    total.surplus()     + fl->surplus()    );
     total.set_desired(    total.desired()     + fl->desired()    );
@@ -2408,14 +2403,13 @@
     total.set_split_births(total.split_births() + fl->split_births());
     total.set_split_deaths(total.split_deaths() + fl->split_deaths());
   }
-  total.print_on(gclog_or_tty, "TOTAL");
-  gclog_or_tty->print_cr("Total free in indexed lists "
-                         SIZE_FORMAT " words", total_free);
-  gclog_or_tty->print("growth: %8.5f  deficit: %8.5f\n",
-    (double)(total.split_births()+total.coal_births()-total.split_deaths()-total.coal_deaths())/
-            (total.prev_sweep() != 0 ? (double)total.prev_sweep() : 1.0),
-    (double)(total.desired() - total.count())/(total.desired() != 0 ? (double)total.desired() : 1.0));
-  _dictionary->print_dict_census();
+  total.print_on(out, "TOTAL");
+  log.debug("Total free in indexed lists " SIZE_FORMAT " words", total_free);
+  log.debug("growth: %8.5f  deficit: %8.5f",
+            (double)(total.split_births()+total.coal_births()-total.split_deaths()-total.coal_deaths())/
+                    (total.prev_sweep() != 0 ? (double)total.prev_sweep() : 1.0),
+            (double)(total.desired() - total.count())/(total.desired() != 0 ? (double)total.desired() : 1.0));
+  _dictionary->print_dict_census(out);
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -2544,10 +2538,7 @@
       // Reset counters for next round
       _global_num_workers[i] = 0;
       _global_num_blocks[i] = 0;
-      if (PrintOldPLAB) {
-        gclog_or_tty->print_cr("[" SIZE_FORMAT "]: " SIZE_FORMAT,
-                               i, (size_t)_blocks_to_claim[i].average());
-      }
+      log_trace(gc, plab)("[" SIZE_FORMAT "]: " SIZE_FORMAT, i, (size_t)_blocks_to_claim[i].average());
     }
   }
 }
@@ -2584,10 +2575,8 @@
           _indexedFreeList[i].set_size(i);
         }
       }
-      if (PrintOldPLAB) {
-        gclog_or_tty->print_cr("%d[" SIZE_FORMAT "]: " SIZE_FORMAT "/" SIZE_FORMAT "/" SIZE_FORMAT,
-                               tid, i, num_retire, _num_blocks[i], (size_t)_blocks_to_claim[i].average());
-      }
+      log_trace(gc, plab)("%d[" SIZE_FORMAT "]: " SIZE_FORMAT "/" SIZE_FORMAT "/" SIZE_FORMAT,
+                          tid, i, num_retire, _num_blocks[i], (size_t)_blocks_to_claim[i].average());
       // Reset stats for next round
       _num_blocks[i]         = 0;
     }
--- a/src/share/vm/gc/cms/compactibleFreeListSpace.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/cms/compactibleFreeListSpace.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -29,6 +29,7 @@
 #include "gc/cms/promotionInfo.hpp"
 #include "gc/shared/blockOffsetTable.hpp"
 #include "gc/shared/space.hpp"
+#include "logging/log.hpp"
 #include "memory/binaryTreeDictionary.hpp"
 #include "memory/freeList.hpp"
 
@@ -275,8 +276,8 @@
   void       verify_objects_initialized() const;
 
   // Statistics reporting helper functions
-  void       reportFreeListStatistics() const;
-  void       reportIndexedFreeListStatistics() const;
+  void       reportFreeListStatistics(const char* title) const;
+  void       reportIndexedFreeListStatistics(outputStream* st) const;
   size_t     maxChunkSizeInIndexedFreeLists() const;
   size_t     numFreeBlocksInIndexedFreeLists() const;
   // Accessor
@@ -450,11 +451,9 @@
   void save_sweep_limit() {
     _sweep_limit = BlockOffsetArrayUseUnallocatedBlock ?
                    unallocated_block() : end();
-    if (CMSTraceSweeper) {
-      gclog_or_tty->print_cr(">>>>> Saving sweep limit " PTR_FORMAT
-                             "  for space [" PTR_FORMAT "," PTR_FORMAT ") <<<<<<",
-                             p2i(_sweep_limit), p2i(bottom()), p2i(end()));
-    }
+    log_develop_trace(gc, sweep)(">>>>> Saving sweep limit " PTR_FORMAT
+                                 "  for space [" PTR_FORMAT "," PTR_FORMAT ") <<<<<<",
+                                 p2i(_sweep_limit), p2i(bottom()), p2i(end()));
   }
   NOT_PRODUCT(
     void clear_sweep_limit() { _sweep_limit = NULL; }
--- a/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -47,13 +47,14 @@
 #include "gc/shared/gcPolicyCounters.hpp"
 #include "gc/shared/gcTimer.hpp"
 #include "gc/shared/gcTrace.hpp"
-#include "gc/shared/gcTraceTime.hpp"
+#include "gc/shared/gcTraceTime.inline.hpp"
 #include "gc/shared/genCollectedHeap.hpp"
 #include "gc/shared/genOopClosures.inline.hpp"
 #include "gc/shared/isGCActiveMark.hpp"
 #include "gc/shared/referencePolicy.hpp"
 #include "gc/shared/strongRootsScope.hpp"
 #include "gc/shared/taskqueue.inline.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.hpp"
 #include "memory/iterator.inline.hpp"
 #include "memory/padded.hpp"
@@ -65,6 +66,7 @@
 #include "runtime/handles.inline.hpp"
 #include "runtime/java.hpp"
 #include "runtime/orderAccess.inline.hpp"
+#include "runtime/timer.hpp"
 #include "runtime/vmThread.hpp"
 #include "services/memoryService.hpp"
 #include "services/runtimeService.hpp"
@@ -367,13 +369,9 @@
     cms_adjustment = cms_adjustment * cms_free_adjustment_factor(cms_free);
     cms_free_dbl = cms_free_dbl * cms_adjustment;
 
-    if (PrintGCDetails && Verbose) {
-      gclog_or_tty->print_cr("CMSStats::time_until_cms_gen_full: cms_free "
-        SIZE_FORMAT " expected_promotion " SIZE_FORMAT,
-        cms_free, expected_promotion);
-      gclog_or_tty->print_cr("  cms_free_dbl %f cms_consumption_rate %f",
-        cms_free_dbl, cms_consumption_rate() + 1.0);
-    }
+    log_trace(gc)("CMSStats::time_until_cms_gen_full: cms_free " SIZE_FORMAT " expected_promotion " SIZE_FORMAT,
+                  cms_free, expected_promotion);
+    log_trace(gc)("  cms_free_dbl %f cms_consumption_rate %f", cms_free_dbl, cms_consumption_rate() + 1.0);
     // Add 1 in case the consumption rate goes to zero.
     return cms_free_dbl / (cms_consumption_rate() + 1.0);
   }
@@ -402,12 +400,8 @@
   // If a concurrent mode failure occurred recently, we want to be
   // more conservative and halve our expected time_until_cms_gen_full()
   if (work > deadline) {
-    if (Verbose && PrintGCDetails) {
-      gclog_or_tty->print(
-        " CMSCollector: collect because of anticipated promotion "
-        "before full %3.7f + %3.7f > %3.7f ", cms_duration(),
-        gc0_period(), time_until_cms_gen_full());
-    }
+    log_develop_trace(gc)("CMSCollector: collect because of anticipated promotion before full %3.7f + %3.7f > %3.7f ",
+                          cms_duration(), gc0_period(), time_until_cms_gen_full());
     return 0.0;
   }
   return work - deadline;
@@ -669,31 +663,6 @@
 }
 #endif
 
-void ConcurrentMarkSweepGeneration::printOccupancy(const char *s) {
-  GenCollectedHeap* gch = GenCollectedHeap::heap();
-  if (PrintGCDetails) {
-    // I didn't want to change the logging when removing the level concept,
-    // but I guess this logging could say "old" or something instead of "1".
-    assert(gch->is_old_gen(this),
-           "The CMS generation should be the old generation");
-    uint level = 1;
-    if (Verbose) {
-      gclog_or_tty->print("[%u %s-%s: " SIZE_FORMAT "(" SIZE_FORMAT ")]",
-        level, short_name(), s, used(), capacity());
-    } else {
-      gclog_or_tty->print("[%u %s-%s: " SIZE_FORMAT "K(" SIZE_FORMAT "K)]",
-        level, short_name(), s, used() / K, capacity() / K);
-    }
-  }
-  if (Verbose) {
-    gclog_or_tty->print(" " SIZE_FORMAT "(" SIZE_FORMAT ")",
-              gch->used(), gch->capacity());
-  } else {
-    gclog_or_tty->print(" " SIZE_FORMAT "K(" SIZE_FORMAT "K)",
-              gch->used() / K, gch->capacity() / K);
-  }
-}
-
 size_t
 ConcurrentMarkSweepGeneration::contiguous_available() const {
   // dld proposes an improvement in precision here. If the committed
@@ -717,21 +686,18 @@
   size_t available = max_available();
   size_t av_promo  = (size_t)gc_stats()->avg_promoted()->padded_average();
   bool   res = (available >= av_promo) || (available >= max_promotion_in_bytes);
-  if (Verbose && PrintGCDetails) {
-    gclog_or_tty->print_cr(
-      "CMS: promo attempt is%s safe: available(" SIZE_FORMAT ") %s av_promo(" SIZE_FORMAT "),"
-      "max_promo(" SIZE_FORMAT ")",
-      res? "":" not", available, res? ">=":"<",
-      av_promo, max_promotion_in_bytes);
-  }
+  log_trace(gc, promotion)("CMS: promo attempt is%s safe: available(" SIZE_FORMAT ") %s av_promo(" SIZE_FORMAT "), max_promo(" SIZE_FORMAT ")",
+                           res? "":" not", available, res? ">=":"<", av_promo, max_promotion_in_bytes);
   return res;
 }
 
 // At a promotion failure dump information on block layout in heap
 // (cms old generation).
 void ConcurrentMarkSweepGeneration::promotion_failure_occurred() {
-  if (CMSDumpAtPromotionFailure) {
-    cmsSpace()->dump_at_safepoint_with_locks(collector(), gclog_or_tty);
+  LogHandle(gc, promotion) log;
+  if (log.is_trace()) {
+    ResourceMark rm;
+    cmsSpace()->dump_at_safepoint_with_locks(collector(), log.trace_stream());
   }
 }
 
@@ -787,27 +753,26 @@
     size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
     assert(desired_capacity >= capacity(), "invalid expansion size");
     size_t expand_bytes = MAX2(desired_capacity - capacity(), MinHeapDeltaBytes);
-    if (PrintGCDetails && Verbose) {
+    LogHandle(gc) log;
+    if (log.is_trace()) {
       size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
-      gclog_or_tty->print_cr("\nFrom compute_new_size: ");
-      gclog_or_tty->print_cr("  Free fraction %f", free_percentage);
-      gclog_or_tty->print_cr("  Desired free fraction %f", desired_free_percentage);
-      gclog_or_tty->print_cr("  Maximum free fraction %f", maximum_free_percentage);
-      gclog_or_tty->print_cr("  Capacity " SIZE_FORMAT, capacity() / 1000);
-      gclog_or_tty->print_cr("  Desired capacity " SIZE_FORMAT, desired_capacity / 1000);
+      log.trace("From compute_new_size: ");
+      log.trace("  Free fraction %f", free_percentage);
+      log.trace("  Desired free fraction %f", desired_free_percentage);
+      log.trace("  Maximum free fraction %f", maximum_free_percentage);
+      log.trace("  Capacity " SIZE_FORMAT, capacity() / 1000);
+      log.trace("  Desired capacity " SIZE_FORMAT, desired_capacity / 1000);
       GenCollectedHeap* gch = GenCollectedHeap::heap();
       assert(gch->is_old_gen(this), "The CMS generation should always be the old generation");
       size_t young_size = gch->young_gen()->capacity();
-      gclog_or_tty->print_cr("  Young gen size " SIZE_FORMAT, young_size / 1000);
-      gclog_or_tty->print_cr("  unsafe_max_alloc_nogc " SIZE_FORMAT, unsafe_max_alloc_nogc() / 1000);
-      gclog_or_tty->print_cr("  contiguous available " SIZE_FORMAT, contiguous_available() / 1000);
-      gclog_or_tty->print_cr("  Expand by " SIZE_FORMAT " (bytes)", expand_bytes);
+      log.trace("  Young gen size " SIZE_FORMAT, young_size / 1000);
+      log.trace("  unsafe_max_alloc_nogc " SIZE_FORMAT, unsafe_max_alloc_nogc() / 1000);
+      log.trace("  contiguous available " SIZE_FORMAT, contiguous_available() / 1000);
+      log.trace("  Expand by " SIZE_FORMAT " (bytes)", expand_bytes);
     }
     // safe if expansion fails
     expand_for_gc_cause(expand_bytes, 0, CMSExpansionCause::_satisfy_free_ratio);
-    if (PrintGCDetails && Verbose) {
-      gclog_or_tty->print_cr("  Expanded free fraction %f", ((double) free()) / capacity());
-    }
+    log.trace("  Expanded free fraction %f", ((double) free()) / capacity());
   } else {
     size_t desired_capacity = (size_t)(used() / ((double) 1 - desired_free_percentage));
     assert(desired_capacity <= capacity(), "invalid expansion size");
@@ -1145,10 +1110,7 @@
 
 bool CMSCollector::shouldConcurrentCollect() {
   if (_full_gc_requested) {
-    if (Verbose && PrintGCDetails) {
-      gclog_or_tty->print_cr("CMSCollector: collect because of explicit "
-                             " gc request (or gc_locker)");
-    }
+    log_trace(gc)("CMSCollector: collect because of explicit  gc request (or gc_locker)");
     return true;
   }
 
@@ -1156,24 +1118,21 @@
   // ------------------------------------------------------------------
   // Print out lots of information which affects the initiation of
   // a collection.
-  if (PrintCMSInitiationStatistics && stats().valid()) {
-    gclog_or_tty->print("CMSCollector shouldConcurrentCollect: ");
-    gclog_or_tty->stamp();
-    gclog_or_tty->cr();
-    stats().print_on(gclog_or_tty);
-    gclog_or_tty->print_cr("time_until_cms_gen_full %3.7f",
-      stats().time_until_cms_gen_full());
-    gclog_or_tty->print_cr("free=" SIZE_FORMAT, _cmsGen->free());
-    gclog_or_tty->print_cr("contiguous_available=" SIZE_FORMAT,
-                           _cmsGen->contiguous_available());
-    gclog_or_tty->print_cr("promotion_rate=%g", stats().promotion_rate());
-    gclog_or_tty->print_cr("cms_allocation_rate=%g", stats().cms_allocation_rate());
-    gclog_or_tty->print_cr("occupancy=%3.7f", _cmsGen->occupancy());
-    gclog_or_tty->print_cr("initiatingOccupancy=%3.7f", _cmsGen->initiating_occupancy());
-    gclog_or_tty->print_cr("cms_time_since_begin=%3.7f", stats().cms_time_since_begin());
-    gclog_or_tty->print_cr("cms_time_since_end=%3.7f", stats().cms_time_since_end());
-    gclog_or_tty->print_cr("metadata initialized %d",
-      MetaspaceGC::should_concurrent_collect());
+  LogHandle(gc) log;
+  if (log.is_trace() && stats().valid()) {
+    log.trace("CMSCollector shouldConcurrentCollect: ");
+    ResourceMark rm;
+    stats().print_on(log.debug_stream());
+    log.trace("time_until_cms_gen_full %3.7f", stats().time_until_cms_gen_full());
+    log.trace("free=" SIZE_FORMAT, _cmsGen->free());
+    log.trace("contiguous_available=" SIZE_FORMAT, _cmsGen->contiguous_available());
+    log.trace("promotion_rate=%g", stats().promotion_rate());
+    log.trace("cms_allocation_rate=%g", stats().cms_allocation_rate());
+    log.trace("occupancy=%3.7f", _cmsGen->occupancy());
+    log.trace("initiatingOccupancy=%3.7f", _cmsGen->initiating_occupancy());
+    log.trace("cms_time_since_begin=%3.7f", stats().cms_time_since_begin());
+    log.trace("cms_time_since_end=%3.7f", stats().cms_time_since_end());
+    log.trace("metadata initialized %d", MetaspaceGC::should_concurrent_collect());
   }
   // ------------------------------------------------------------------
 
@@ -1191,12 +1150,8 @@
       // this branch will not fire after the first successful CMS
       // collection because the stats should then be valid.
       if (_cmsGen->occupancy() >= _bootstrap_occupancy) {
-        if (Verbose && PrintGCDetails) {
-          gclog_or_tty->print_cr(
-            " CMSCollector: collect for bootstrapping statistics:"
-            " occupancy = %f, boot occupancy = %f", _cmsGen->occupancy(),
-            _bootstrap_occupancy);
-        }
+        log_trace(gc)(" CMSCollector: collect for bootstrapping statistics: occupancy = %f, boot occupancy = %f",
+                      _cmsGen->occupancy(), _bootstrap_occupancy);
         return true;
       }
     }
@@ -1208,9 +1163,7 @@
   // XXX We need to make sure that the gen expansion
   // criterion dovetails well with this. XXX NEED TO FIX THIS
   if (_cmsGen->should_concurrent_collect()) {
-    if (Verbose && PrintGCDetails) {
-      gclog_or_tty->print_cr("CMS old gen initiated");
-    }
+    log_trace(gc)("CMS old gen initiated");
     return true;
   }
 
@@ -1221,16 +1174,12 @@
   assert(gch->collector_policy()->is_generation_policy(),
          "You may want to check the correctness of the following");
   if (gch->incremental_collection_will_fail(true /* consult_young */)) {
-    if (Verbose && PrintGCDetails) {
-      gclog_or_tty->print("CMSCollector: collect because incremental collection will fail ");
-    }
+    log_trace(gc)("CMSCollector: collect because incremental collection will fail ");
     return true;
   }
 
   if (MetaspaceGC::should_concurrent_collect()) {
-    if (Verbose && PrintGCDetails) {
-      gclog_or_tty->print("CMSCollector: collect for metadata allocation ");
-    }
+    log_trace(gc)("CMSCollector: collect for metadata allocation ");
     return true;
   }
 
@@ -1244,13 +1193,11 @@
     // Check the CMS time since begin (we do not check the stats validity
     // as we want to be able to trigger the first CMS cycle as well)
     if (stats().cms_time_since_begin() >= (CMSTriggerInterval / ((double) MILLIUNITS))) {
-      if (Verbose && PrintGCDetails) {
-        if (stats().valid()) {
-          gclog_or_tty->print_cr("CMSCollector: collect because of trigger interval (time since last begin %3.7f secs)",
-                                 stats().cms_time_since_begin());
-        } else {
-          gclog_or_tty->print_cr("CMSCollector: collect because of trigger interval (first collection)");
-        }
+      if (stats().valid()) {
+        log_trace(gc)("CMSCollector: collect because of trigger interval (time since last begin %3.7f secs)",
+                      stats().cms_time_since_begin());
+      } else {
+        log_trace(gc)("CMSCollector: collect because of trigger interval (first collection)");
       }
       return true;
     }
@@ -1293,20 +1240,15 @@
 
   assert_lock_strong(freelistLock());
   if (occupancy() > initiating_occupancy()) {
-    if (PrintGCDetails && Verbose) {
-      gclog_or_tty->print(" %s: collect because of occupancy %f / %f  ",
-        short_name(), occupancy(), initiating_occupancy());
-    }
+    log_trace(gc)(" %s: collect because of occupancy %f / %f  ",
+                  short_name(), occupancy(), initiating_occupancy());
     return true;
   }
   if (UseCMSInitiatingOccupancyOnly) {
     return false;
   }
   if (expansion_cause() == CMSExpansionCause::_satisfy_allocation) {
-    if (PrintGCDetails && Verbose) {
-      gclog_or_tty->print(" %s: collect because expanded for allocation ",
-        short_name());
-    }
+    log_trace(gc)(" %s: collect because expanded for allocation ", short_name());
     return true;
   }
   return false;
@@ -1363,13 +1305,9 @@
 
 void CMSCollector::report_concurrent_mode_interruption() {
   if (is_external_interruption()) {
-    if (PrintGCDetails) {
-      gclog_or_tty->print(" (concurrent mode interrupted)");
-    }
+    log_debug(gc)("Concurrent mode interrupted");
   } else {
-    if (PrintGCDetails) {
-      gclog_or_tty->print(" (concurrent mode failure)");
-    }
+    log_debug(gc)("Concurrent mode failure");
     _gc_tracer_cm->report_concurrent_mode_failure();
   }
 }
@@ -1503,11 +1441,9 @@
          "VM thread should have CMS token");
   getFreelistLocks();
   bitMapLock()->lock_without_safepoint_check();
-  if (TraceCMSState) {
-    gclog_or_tty->print_cr("CMS foreground collector has asked for control "
-      INTPTR_FORMAT " with first state %d", p2i(Thread::current()), first_state);
-    gclog_or_tty->print_cr("    gets control with state %d", _collectorState);
-  }
+  log_debug(gc, state)("CMS foreground collector has asked for control " INTPTR_FORMAT " with first state %d",
+                       p2i(Thread::current()), first_state);
+  log_debug(gc, state)("    gets control with state %d", _collectorState);
 
   // Inform cms gen if this was due to partial collection failing.
   // The CMS gen may use this fact to determine its expansion policy.
@@ -1581,7 +1517,7 @@
   SerialOldTracer* gc_tracer = GenMarkSweep::gc_tracer();
   gc_tracer->report_gc_start(gch->gc_cause(), gc_timer->gc_start());
 
-  GCTraceTime t("CMS:MSC ", PrintGCDetails && Verbose, true, NULL);
+  GCTraceTime(Trace, gc) t("CMS:MSC");
 
   // Temporarily widen the span of the weak reference processing to
   // the entire heap.
@@ -1666,33 +1602,34 @@
 }
 
 void CMSCollector::print_eden_and_survivor_chunk_arrays() {
+  LogHandle(gc, heap) log;
+  if (!log.is_trace()) {
+    return;
+  }
+
   ContiguousSpace* eden_space = _young_gen->eden();
   ContiguousSpace* from_space = _young_gen->from();
   ContiguousSpace* to_space   = _young_gen->to();
   // Eden
   if (_eden_chunk_array != NULL) {
-    gclog_or_tty->print_cr("eden " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
-                           p2i(eden_space->bottom()), p2i(eden_space->top()),
-                           p2i(eden_space->end()), eden_space->capacity());
-    gclog_or_tty->print_cr("_eden_chunk_index=" SIZE_FORMAT ", "
-                           "_eden_chunk_capacity=" SIZE_FORMAT,
-                           _eden_chunk_index, _eden_chunk_capacity);
+    log.trace("eden " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
+              p2i(eden_space->bottom()), p2i(eden_space->top()),
+              p2i(eden_space->end()), eden_space->capacity());
+    log.trace("_eden_chunk_index=" SIZE_FORMAT ", _eden_chunk_capacity=" SIZE_FORMAT,
+              _eden_chunk_index, _eden_chunk_capacity);
     for (size_t i = 0; i < _eden_chunk_index; i++) {
-      gclog_or_tty->print_cr("_eden_chunk_array[" SIZE_FORMAT "]=" PTR_FORMAT,
-                             i, p2i(_eden_chunk_array[i]));
+      log.trace("_eden_chunk_array[" SIZE_FORMAT "]=" PTR_FORMAT, i, p2i(_eden_chunk_array[i]));
     }
   }
   // Survivor
   if (_survivor_chunk_array != NULL) {
-    gclog_or_tty->print_cr("survivor " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
-                           p2i(from_space->bottom()), p2i(from_space->top()),
-                           p2i(from_space->end()), from_space->capacity());
-    gclog_or_tty->print_cr("_survivor_chunk_index=" SIZE_FORMAT ", "
-                           "_survivor_chunk_capacity=" SIZE_FORMAT,
-                           _survivor_chunk_index, _survivor_chunk_capacity);
+    log.trace("survivor " PTR_FORMAT "-" PTR_FORMAT "-" PTR_FORMAT "(" SIZE_FORMAT ")",
+              p2i(from_space->bottom()), p2i(from_space->top()),
+              p2i(from_space->end()), from_space->capacity());
+    log.trace("_survivor_chunk_index=" SIZE_FORMAT ", _survivor_chunk_capacity=" SIZE_FORMAT,
+              _survivor_chunk_index, _survivor_chunk_capacity);
     for (size_t i = 0; i < _survivor_chunk_index; i++) {
-      gclog_or_tty->print_cr("_survivor_chunk_array[" SIZE_FORMAT "]=" PTR_FORMAT,
-                             i, p2i(_survivor_chunk_array[i]));
+      log.trace("_survivor_chunk_array[" SIZE_FORMAT "]=" PTR_FORMAT, i, p2i(_survivor_chunk_array[i]));
     }
   }
 }
@@ -1781,11 +1718,7 @@
     _collection_count_start = gch->total_full_collections();
   }
 
-  // Used for PrintGC
-  size_t prev_used = 0;
-  if (PrintGC && Verbose) {
-    prev_used = _cmsGen->used();
-  }
+  size_t prev_used = _cmsGen->used();
 
   // The change of the collection state is normally done at this level;
   // the exceptions are phases that are executed while the world is
@@ -1796,10 +1729,8 @@
   // while the world is stopped because the foreground collector already
   // has the world stopped and would deadlock.
   while (_collectorState != Idling) {
-    if (TraceCMSState) {
-      gclog_or_tty->print_cr("Thread " INTPTR_FORMAT " in CMS state %d",
-        p2i(Thread::current()), _collectorState);
-    }
+    log_debug(gc, state)("Thread " INTPTR_FORMAT " in CMS state %d",
+                         p2i(Thread::current()), _collectorState);
     // The foreground collector
     //   holds the Heap_lock throughout its collection.
     //   holds the CMS token (but not the lock)
@@ -1829,11 +1760,8 @@
         // done this round.
         assert(_foregroundGCShouldWait == false, "We set it to false in "
                "waitForForegroundGC()");
-        if (TraceCMSState) {
-          gclog_or_tty->print_cr("CMS Thread " INTPTR_FORMAT
-            " exiting collection CMS state %d",
-            p2i(Thread::current()), _collectorState);
-        }
+        log_debug(gc, state)("CMS Thread " INTPTR_FORMAT " exiting collection CMS state %d",
+                             p2i(Thread::current()), _collectorState);
         return;
       } else {
         // The background collector can run but check to see if the
@@ -1937,10 +1865,8 @@
         ShouldNotReachHere();
         break;
     }
-    if (TraceCMSState) {
-      gclog_or_tty->print_cr("  Thread " INTPTR_FORMAT " done - next CMS state %d",
-        p2i(Thread::current()), _collectorState);
-    }
+    log_debug(gc, state)("  Thread " INTPTR_FORMAT " done - next CMS state %d",
+                         p2i(Thread::current()), _collectorState);
     assert(_foregroundGCShouldWait, "block post-condition");
   }
 
@@ -1959,14 +1885,10 @@
     assert(!ConcurrentMarkSweepThread::cms_thread_has_cms_token(),
            "Possible deadlock");
   }
-  if (TraceCMSState) {
-    gclog_or_tty->print_cr("CMS Thread " INTPTR_FORMAT
-      " exiting collection CMS state %d",
-      p2i(Thread::current()), _collectorState);
-  }
-  if (PrintGC && Verbose) {
-    _cmsGen->print_heap_change(prev_used);
-  }
+  log_debug(gc, state)("CMS Thread " INTPTR_FORMAT " exiting collection CMS state %d",
+                       p2i(Thread::current()), _collectorState);
+  log_info(gc, heap)("Old: " SIZE_FORMAT "K->" SIZE_FORMAT "K("  SIZE_FORMAT "K)",
+                     prev_used / K, _cmsGen->used()/K, _cmsGen->capacity() /K);
 }
 
 void CMSCollector::register_gc_start(GCCause::Cause cause) {
@@ -2018,10 +1940,8 @@
       ConcurrentMarkSweepThread::CMS_cms_wants_token);
     // Get a possibly blocked foreground thread going
     CGC_lock->notify();
-    if (TraceCMSState) {
-      gclog_or_tty->print_cr("CMS Thread " INTPTR_FORMAT " waiting at CMS state %d",
-        p2i(Thread::current()), _collectorState);
-    }
+    log_debug(gc, state)("CMS Thread " INTPTR_FORMAT " waiting at CMS state %d",
+                         p2i(Thread::current()), _collectorState);
     while (_foregroundGCIsActive) {
       CGC_lock->wait(Mutex::_no_safepoint_check_flag);
     }
@@ -2030,10 +1950,8 @@
     ConcurrentMarkSweepThread::clear_CMS_flag(
       ConcurrentMarkSweepThread::CMS_cms_wants_token);
   }
-  if (TraceCMSState) {
-    gclog_or_tty->print_cr("CMS Thread " INTPTR_FORMAT " continuing at CMS state %d",
-      p2i(Thread::current()), _collectorState);
-  }
+  log_debug(gc, state)("CMS Thread " INTPTR_FORMAT " continuing at CMS state %d",
+                       p2i(Thread::current()), _collectorState);
   return res;
 }
 
@@ -2130,11 +2048,8 @@
   NOT_PRODUCT(
     assert(_numObjectsPromoted == 0, "check");
     assert(_numWordsPromoted   == 0, "check");
-    if (Verbose && PrintGC) {
-      gclog_or_tty->print("Allocated " SIZE_FORMAT " objects, "
-                          SIZE_FORMAT " bytes concurrently",
-      _numObjectsAllocated, _numWordsAllocated*sizeof(HeapWord));
-    }
+    log_develop_trace(gc, alloc)("Allocated " SIZE_FORMAT " objects, " SIZE_FORMAT " bytes concurrently",
+                                 _numObjectsAllocated, _numWordsAllocated*sizeof(HeapWord));
     _numObjectsAllocated = 0;
     _numWordsAllocated   = 0;
   )
@@ -2211,21 +2126,15 @@
   NOT_PRODUCT(
     assert(_numObjectsAllocated == 0, "check");
     assert(_numWordsAllocated == 0, "check");
-    if (Verbose && PrintGC) {
-      gclog_or_tty->print("Promoted " SIZE_FORMAT " objects, "
-                          SIZE_FORMAT " bytes",
-                 _numObjectsPromoted, _numWordsPromoted*sizeof(HeapWord));
-    }
+    log_develop_trace(gc, promotion)("Promoted " SIZE_FORMAT " objects, " SIZE_FORMAT " bytes",
+                                     _numObjectsPromoted, _numWordsPromoted*sizeof(HeapWord));
     _numObjectsPromoted = 0;
     _numWordsPromoted   = 0;
   )
 
-  if (PrintGC && Verbose) {
-    // Call down the chain in contiguous_available needs the freelistLock
-    // so print this out before releasing the freeListLock.
-    gclog_or_tty->print(" Contiguous available " SIZE_FORMAT " bytes ",
-                        contiguous_available());
-  }
+  // Call down the chain in contiguous_available needs the freelistLock
+  // so print this out before releasing the freeListLock.
+  log_develop_trace(gc)(" Contiguous available " SIZE_FORMAT " bytes ", contiguous_available());
 }
 
 #ifndef PRODUCT
@@ -2309,8 +2218,10 @@
   bool do_bit(size_t offset) {
     HeapWord* addr = _marks->offsetToHeapWord(offset);
     if (!_marks->isMarked(addr)) {
-      oop(addr)->print_on(gclog_or_tty);
-      gclog_or_tty->print_cr(" (" INTPTR_FORMAT " should have been marked)", p2i(addr));
+      LogHandle(gc, verify) log;
+      ResourceMark rm;
+      oop(addr)->print_on(log.info_stream());
+      log.info(" (" INTPTR_FORMAT " should have been marked)", p2i(addr));
       _failed = true;
     }
     return true;
@@ -2319,8 +2230,8 @@
   bool failed() { return _failed; }
 };
 
-bool CMSCollector::verify_after_remark(bool silent) {
-  if (!silent) gclog_or_tty->print(" [Verifying CMS Marking... ");
+bool CMSCollector::verify_after_remark() {
+  GCTraceTime(Info, gc, verify) tm("Verifying CMS Marking.");
   MutexLockerEx ml(verification_mark_bm()->lock(), Mutex::_no_safepoint_check_flag);
   static bool init = false;
 
@@ -2383,7 +2294,6 @@
     warning("Unrecognized value " UINTX_FORMAT " for CMSRemarkVerifyVariant",
             CMSRemarkVerifyVariant);
   }
-  if (!silent) gclog_or_tty->print(" done] ");
   return true;
 }
 
@@ -2435,8 +2345,10 @@
   VerifyMarkedClosure vcl(markBitMap());
   verification_mark_bm()->iterate(&vcl);
   if (vcl.failed()) {
-    gclog_or_tty->print("Verification failed");
-    gch->print_on(gclog_or_tty);
+    LogHandle(gc, verify) log;
+    log.info("Verification failed");
+    ResourceMark rm;
+    gch->print_on(log.info_stream());
     fatal("CMS: failed marking verification after remark");
   }
 }
@@ -2729,10 +2641,7 @@
   // a new CMS cycle.
   if (success) {
     set_expansion_cause(cause);
-    if (PrintGCDetails && Verbose) {
-      gclog_or_tty->print_cr("Expanded CMS gen for %s",
-        CMSExpansionCause::to_string(cause));
-    }
+    log_trace(gc)("Expanded CMS gen for %s",  CMSExpansionCause::to_string(cause));
   }
 }
 
@@ -2800,9 +2709,7 @@
 void ConcurrentMarkSweepGeneration::shrink_free_list_by(size_t bytes) {
   assert_locked_or_safepoint(Heap_lock);
   assert_lock_strong(freelistLock());
-  if (PrintGCDetails && Verbose) {
-    warning("Shrinking of CMS not yet implemented");
-  }
+  log_trace(gc)("Shrinking of CMS not yet implemented");
   return;
 }
 
@@ -2812,63 +2719,35 @@
 class CMSPhaseAccounting: public StackObj {
  public:
   CMSPhaseAccounting(CMSCollector *collector,
-                     const char *phase,
-                     bool print_cr = true);
+                     const char *title);
   ~CMSPhaseAccounting();
 
  private:
   CMSCollector *_collector;
-  const char *_phase;
-  elapsedTimer _wallclock;
-  bool _print_cr;
+  const char *_title;
+  GCTraceConcTime(Info, gc) _trace_time;
 
  public:
   // Not MT-safe; so do not pass around these StackObj's
   // where they may be accessed by other threads.
   jlong wallclock_millis() {
-    assert(_wallclock.is_active(), "Wall clock should not stop");
-    _wallclock.stop();  // to record time
-    jlong ret = _wallclock.milliseconds();
-    _wallclock.start(); // restart
-    return ret;
+    return TimeHelper::counter_to_millis(os::elapsed_counter() - _trace_time.start_time());
   }
 };
 
 CMSPhaseAccounting::CMSPhaseAccounting(CMSCollector *collector,
-                                       const char *phase,
-                                       bool print_cr) :
-  _collector(collector), _phase(phase), _print_cr(print_cr) {
-
-  if (PrintCMSStatistics != 0) {
-    _collector->resetYields();
-  }
-  if (PrintGCDetails) {
-    gclog_or_tty->gclog_stamp();
-    gclog_or_tty->print_cr("[%s-concurrent-%s-start]",
-      _collector->cmsGen()->short_name(), _phase);
-  }
+                                       const char *title) :
+  _collector(collector), _title(title), _trace_time(title) {
+
+  _collector->resetYields();
   _collector->resetTimer();
-  _wallclock.start();
   _collector->startTimer();
 }
 
 CMSPhaseAccounting::~CMSPhaseAccounting() {
-  assert(_wallclock.is_active(), "Wall clock should not have stopped");
   _collector->stopTimer();
-  _wallclock.stop();
-  if (PrintGCDetails) {
-    gclog_or_tty->gclog_stamp();
-    gclog_or_tty->print("[%s-concurrent-%s: %3.3f/%3.3f secs]",
-                 _collector->cmsGen()->short_name(),
-                 _phase, _collector->timerValue(), _wallclock.seconds());
-    if (_print_cr) {
-      gclog_or_tty->cr();
-    }
-    if (PrintCMSStatistics != 0) {
-      gclog_or_tty->print_cr(" (CMS-concurrent-%s yielded %d times)", _phase,
-                    _collector->yields());
-    }
-  }
+  log_debug(gc)("Concurrent active time: %.3fms", TimeHelper::counter_to_seconds(_collector->timerTicks()));
+  log_trace(gc)(" (CMS %s yielded %d times)", _title, _collector->yields());
 }
 
 // CMS work
@@ -2935,8 +2814,7 @@
   // CMS collection cycle.
   setup_cms_unloading_and_verification_state();
 
-  NOT_PRODUCT(GCTraceTime t("\ncheckpointRootsInitialWork",
-    PrintGCDetails && Verbose, true, _gc_timer_cm);)
+  GCTraceTime(Trace, gc) ts("checkpointRootsInitialWork", _gc_timer_cm);
 
   // Reset all the PLAB chunk arrays if necessary.
   if (_survivor_plab_array != NULL && !CMSPLABRecordAlways) {
@@ -2967,9 +2845,7 @@
   // the klasses. The claimed marks need to be cleared before marking starts.
   ClassLoaderDataGraph::clear_claimed_marks();
 
-  if (CMSPrintEdenSurvivorChunks) {
-    print_eden_and_survivor_chunk_arrays();
-  }
+  print_eden_and_survivor_chunk_arrays();
 
   {
 #if defined(COMPILER2) || INCLUDE_JVMCI
@@ -3040,17 +2916,15 @@
   // weak ref discovery by the young generation collector.
 
   CMSTokenSyncWithLocks ts(true, bitMapLock());
-  TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
-  CMSPhaseAccounting pa(this, "mark", !PrintGCDetails);
+  GCTraceCPUTime tcpu;
+  CMSPhaseAccounting pa(this, "Concrurrent Mark");
   bool res = markFromRootsWork();
   if (res) {
     _collectorState = Precleaning;
   } else { // We failed and a foreground collection wants to take over
     assert(_foregroundGCIsActive, "internal state inconsistency");
     assert(_restart_addr == NULL,  "foreground will restart from scratch");
-    if (PrintGCDetails) {
-      gclog_or_tty->print_cr("bailing out to foreground collection");
-    }
+    log_debug(gc)("bailing out to foreground collection");
   }
   verify_overflow_empty();
   return res;
@@ -3255,22 +3129,14 @@
   _timer.start();
   do_scan_and_mark(worker_id, _cms_space);
   _timer.stop();
-  if (PrintCMSStatistics != 0) {
-    gclog_or_tty->print_cr("Finished cms space scanning in %dth thread: %3.3f sec",
-      worker_id, _timer.seconds());
-      // XXX: need xxx/xxx type of notation, two timers
-  }
+  log_trace(gc, task)("Finished cms space scanning in %dth thread: %3.3f sec", worker_id, _timer.seconds());
 
   // ... do work stealing
   _timer.reset();
   _timer.start();
   do_work_steal(worker_id);
   _timer.stop();
-  if (PrintCMSStatistics != 0) {
-    gclog_or_tty->print_cr("Finished work stealing in %dth thread: %3.3f sec",
-      worker_id, _timer.seconds());
-      // XXX: need xxx/xxx type of notation, two timers
-  }
+  log_trace(gc, task)("Finished work stealing in %dth thread: %3.3f sec", worker_id, _timer.seconds());
   assert(_collector->_markStack.isEmpty(), "Should have been emptied");
   assert(work_queue(worker_id)->size() == 0, "Should have been emptied");
   // Note that under the current task protocol, the
@@ -3485,10 +3351,7 @@
       if (simulate_overflow ||
           !(_work_queue->push(obj) || _overflow_stack->par_push(obj))) {
         // stack overflow
-        if (PrintCMSStatistics != 0) {
-          gclog_or_tty->print_cr("CMS marking stack overflow (benign) at "
-                                 SIZE_FORMAT, _overflow_stack->capacity());
-        }
+        log_trace(gc)("CMS marking stack overflow (benign) at " SIZE_FORMAT, _overflow_stack->capacity());
         // We cannot assert that the overflow stack is full because
         // it may have been emptied since.
         assert(simulate_overflow ||
@@ -3573,9 +3436,7 @@
   _bit_map_lock->unlock();
   ConcurrentMarkSweepThread::desynchronize(true);
   _collector->stopTimer();
-  if (PrintCMSStatistics != 0) {
-    _collector->incrementYields();
-  }
+  _collector->incrementYields();
 
   // It is possible for whichever thread initiated the yield request
   // not to get a chance to wake up and take the bitmap lock between
@@ -3737,8 +3598,8 @@
     } else {
       _start_sampling = false;
     }
-    TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
-    CMSPhaseAccounting pa(this, "preclean", !PrintGCDetails);
+    GCTraceCPUTime tcpu;
+    CMSPhaseAccounting pa(this, "Concurrent Preclean");
     preclean_work(CMSPrecleanRefLists1, CMSPrecleanSurvivors1);
   }
   CMSTokenSync x(true); // is cms thread
@@ -3766,8 +3627,8 @@
   // CMSScheduleRemarkEdenSizeThreshold >= max eden size
   // we will never do an actual abortable preclean cycle.
   if (get_eden_used() > CMSScheduleRemarkEdenSizeThreshold) {
-    TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
-    CMSPhaseAccounting pa(this, "abortable-preclean", !PrintGCDetails);
+    GCTraceCPUTime tcpu;
+    CMSPhaseAccounting pa(this, "Concurrent Abortable Preclean");
     // We need more smarts in the abortable preclean
     // loop below to deal with cases where allocation
     // in young gen is very very slow, and our precleaning
@@ -3789,15 +3650,11 @@
       // been at it for too long.
       if ((CMSMaxAbortablePrecleanLoops != 0) &&
           loops >= CMSMaxAbortablePrecleanLoops) {
-        if (PrintGCDetails) {
-          gclog_or_tty->print(" CMS: abort preclean due to loops ");
-        }
+        log_debug(gc)(" CMS: abort preclean due to loops ");
         break;
       }
       if (pa.wallclock_millis() > CMSMaxAbortablePrecleanTime) {
-        if (PrintGCDetails) {
-          gclog_or_tty->print(" CMS: abort preclean due to time ");
-        }
+        log_debug(gc)(" CMS: abort preclean due to time ");
         break;
       }
       // If we are doing little work each iteration, we should
@@ -3810,10 +3667,8 @@
         waited++;
       }
     }
-    if (PrintCMSStatistics > 0) {
-      gclog_or_tty->print(" [" SIZE_FORMAT " iterations, " SIZE_FORMAT " waits, " SIZE_FORMAT " cards)] ",
-                          loops, waited, cumworkdone);
-    }
+    log_trace(gc)(" [" SIZE_FORMAT " iterations, " SIZE_FORMAT " waits, " SIZE_FORMAT " cards)] ",
+                               loops, waited, cumworkdone);
   }
   CMSTokenSync x(true); // is cms thread
   if (_collectorState != Idling) {
@@ -3957,9 +3812,7 @@
        numIter < CMSPrecleanIter;
        numIter++, lastNumCards = curNumCards, cumNumCards += curNumCards) {
     curNumCards  = preclean_mod_union_table(_cmsGen, &smoac_cl);
-    if (Verbose && PrintGCDetails) {
-      gclog_or_tty->print(" (modUnionTable: " SIZE_FORMAT " cards)", curNumCards);
-    }
+    log_trace(gc)(" (modUnionTable: " SIZE_FORMAT " cards)", curNumCards);
     // Either there are very few dirty cards, so re-mark
     // pause will be small anyway, or our pre-cleaning isn't
     // that much faster than the rate at which cards are being
@@ -3979,10 +3832,8 @@
 
   curNumCards = preclean_card_table(_cmsGen, &smoac_cl);
   cumNumCards += curNumCards;
-  if (PrintGCDetails && PrintCMSStatistics != 0) {
-    gclog_or_tty->print_cr(" (cardTable: " SIZE_FORMAT " cards, re-scanned " SIZE_FORMAT " cards, " SIZE_FORMAT " iterations)",
-                  curNumCards, cumNumCards, numIter);
-  }
+  log_trace(gc)(" (cardTable: " SIZE_FORMAT " cards, re-scanned " SIZE_FORMAT " cards, " SIZE_FORMAT " iterations)",
+                             curNumCards, cumNumCards, numIter);
   return cumNumCards;   // as a measure of useful work done
 }
 
@@ -4236,19 +4087,17 @@
   verify_work_stacks_empty();
   verify_overflow_empty();
 
-  if (PrintGCDetails) {
-    gclog_or_tty->print("[YG occupancy: " SIZE_FORMAT " K (" SIZE_FORMAT " K)]",
-                        _young_gen->used() / K,
-                        _young_gen->capacity() / K);
-  }
+  log_debug(gc)("YG occupancy: " SIZE_FORMAT " K (" SIZE_FORMAT " K)",
+                _young_gen->used() / K, _young_gen->capacity() / K);
   {
     if (CMSScavengeBeforeRemark) {
       GenCollectedHeap* gch = GenCollectedHeap::heap();
       // Temporarily set flag to false, GCH->do_collection will
       // expect it to be false and set to true
       FlagSetting fl(gch->_is_gc_active, false);
-      NOT_PRODUCT(GCTraceTime t("Scavenge-Before-Remark",
-        PrintGCDetails && Verbose, true, _gc_timer_cm);)
+
+      GCTraceTime(Trace, gc) tm("Pause Scavenge Before Remark", _gc_timer_cm);
+
       gch->do_collection(true,                      // full (i.e. force, see below)
                          false,                     // !clear_all_soft_refs
                          0,                         // size
@@ -4266,7 +4115,7 @@
 }
 
 void CMSCollector::checkpointRootsFinalWork() {
-  NOT_PRODUCT(GCTraceTime tr("checkpointRootsFinalWork", PrintGCDetails, false, _gc_timer_cm);)
+  GCTraceTime(Trace, gc) tm("checkpointRootsFinalWork", _gc_timer_cm);
 
   assert(haveFreelistLocks(), "must have free list locks");
   assert_lock_strong(bitMapLock());
@@ -4298,9 +4147,7 @@
   // Update the saved marks which may affect the root scans.
   gch->save_marks();
 
-  if (CMSPrintEdenSurvivorChunks) {
-    print_eden_and_survivor_chunk_arrays();
-  }
+  print_eden_and_survivor_chunk_arrays();
 
   {
 #if defined(COMPILER2) || INCLUDE_JVMCI
@@ -4318,10 +4165,10 @@
     // the most recent young generation GC, minus those cleaned up by the
     // concurrent precleaning.
     if (CMSParallelRemarkEnabled) {
-      GCTraceTime t("Rescan (parallel) ", PrintGCDetails, false, _gc_timer_cm);
+      GCTraceTime(Debug, gc) t("Rescan (parallel)", _gc_timer_cm);
       do_remark_parallel();
     } else {
-      GCTraceTime t("Rescan (non-parallel) ", PrintGCDetails, false, _gc_timer_cm);
+      GCTraceTime(Debug, gc) t("Rescan (non-parallel)", _gc_timer_cm);
       do_remark_non_parallel();
     }
   }
@@ -4329,7 +4176,7 @@
   verify_overflow_empty();
 
   {
-    NOT_PRODUCT(GCTraceTime ts("refProcessingWork", PrintGCDetails, false, _gc_timer_cm);)
+    GCTraceTime(Trace, gc) ts("refProcessingWork", _gc_timer_cm);
     refProcessingWork();
   }
   verify_work_stacks_empty();
@@ -4348,13 +4195,8 @@
   size_t ser_ovflw = _ser_pmc_remark_ovflw + _ser_pmc_preclean_ovflw +
                      _ser_kac_ovflw        + _ser_kac_preclean_ovflw;
   if (ser_ovflw > 0) {
-    if (PrintCMSStatistics != 0) {
-      gclog_or_tty->print_cr("Marking stack overflow (benign) "
-        "(pmc_pc=" SIZE_FORMAT ", pmc_rm=" SIZE_FORMAT ", kac=" SIZE_FORMAT
-        ", kac_preclean=" SIZE_FORMAT ")",
-        _ser_pmc_preclean_ovflw, _ser_pmc_remark_ovflw,
-        _ser_kac_ovflw, _ser_kac_preclean_ovflw);
-    }
+    log_trace(gc)("Marking stack overflow (benign) (pmc_pc=" SIZE_FORMAT ", pmc_rm=" SIZE_FORMAT ", kac=" SIZE_FORMAT ", kac_preclean=" SIZE_FORMAT ")",
+                         _ser_pmc_preclean_ovflw, _ser_pmc_remark_ovflw, _ser_kac_ovflw, _ser_kac_preclean_ovflw);
     _markStack.expand();
     _ser_pmc_remark_ovflw = 0;
     _ser_pmc_preclean_ovflw = 0;
@@ -4362,26 +4204,19 @@
     _ser_kac_ovflw = 0;
   }
   if (_par_pmc_remark_ovflw > 0 || _par_kac_ovflw > 0) {
-    if (PrintCMSStatistics != 0) {
-      gclog_or_tty->print_cr("Work queue overflow (benign) "
-        "(pmc_rm=" SIZE_FORMAT ", kac=" SIZE_FORMAT ")",
-        _par_pmc_remark_ovflw, _par_kac_ovflw);
-    }
-    _par_pmc_remark_ovflw = 0;
+     log_trace(gc)("Work queue overflow (benign) (pmc_rm=" SIZE_FORMAT ", kac=" SIZE_FORMAT ")",
+                          _par_pmc_remark_ovflw, _par_kac_ovflw);
+     _par_pmc_remark_ovflw = 0;
     _par_kac_ovflw = 0;
   }
-  if (PrintCMSStatistics != 0) {
-     if (_markStack._hit_limit > 0) {
-       gclog_or_tty->print_cr(" (benign) Hit max stack size limit (" SIZE_FORMAT ")",
-                              _markStack._hit_limit);
-     }
-     if (_markStack._failed_double > 0) {
-       gclog_or_tty->print_cr(" (benign) Failed stack doubling (" SIZE_FORMAT "),"
-                              " current capacity " SIZE_FORMAT,
-                              _markStack._failed_double,
-                              _markStack.capacity());
-     }
-  }
+   if (_markStack._hit_limit > 0) {
+     log_trace(gc)(" (benign) Hit max stack size limit (" SIZE_FORMAT ")",
+                          _markStack._hit_limit);
+   }
+   if (_markStack._failed_double > 0) {
+     log_trace(gc)(" (benign) Failed stack doubling (" SIZE_FORMAT "), current capacity " SIZE_FORMAT,
+                          _markStack._failed_double, _markStack.capacity());
+   }
   _markStack._hit_limit = 0;
   _markStack._failed_double = 0;
 
@@ -4415,11 +4250,7 @@
   {
     work_on_young_gen_roots(worker_id, &par_mri_cl);
     _timer.stop();
-    if (PrintCMSStatistics != 0) {
-      gclog_or_tty->print_cr(
-        "Finished young gen initial mark scan work in %dth thread: %3.3f sec",
-        worker_id, _timer.seconds());
-    }
+    log_trace(gc, task)("Finished young gen initial mark scan work in %dth thread: %3.3f sec", worker_id, _timer.seconds());
   }
 
   // ---------- remaining roots --------------
@@ -4440,11 +4271,7 @@
          || (_collector->CMSCollector::roots_scanning_options() & GenCollectedHeap::SO_AllCodeCache),
          "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops");
   _timer.stop();
-  if (PrintCMSStatistics != 0) {
-    gclog_or_tty->print_cr(
-      "Finished remaining root initial mark scan work in %dth thread: %3.3f sec",
-      worker_id, _timer.seconds());
-  }
+  log_trace(gc, task)("Finished remaining root initial mark scan work in %dth thread: %3.3f sec", worker_id, _timer.seconds());
 }
 
 // Parallel remark task
@@ -4557,11 +4384,7 @@
   {
     work_on_young_gen_roots(worker_id, &par_mrias_cl);
     _timer.stop();
-    if (PrintCMSStatistics != 0) {
-      gclog_or_tty->print_cr(
-        "Finished young gen rescan work in %dth thread: %3.3f sec",
-        worker_id, _timer.seconds());
-    }
+    log_trace(gc, task)("Finished young gen rescan work in %dth thread: %3.3f sec", worker_id, _timer.seconds());
   }
 
   // ---------- remaining roots --------------
@@ -4580,11 +4403,7 @@
          || (_collector->CMSCollector::roots_scanning_options() & GenCollectedHeap::SO_AllCodeCache),
          "if we didn't scan the code cache, we have to be ready to drop nmethods with expired weak oops");
   _timer.stop();
-  if (PrintCMSStatistics != 0) {
-    gclog_or_tty->print_cr(
-      "Finished remaining root rescan work in %dth thread: %3.3f sec",
-      worker_id, _timer.seconds());
-  }
+  log_trace(gc, task)("Finished remaining root rescan work in %dth thread: %3.3f sec",  worker_id, _timer.seconds());
 
   // ---------- unhandled CLD scanning ----------
   if (worker_id == 0) { // Single threaded at the moment.
@@ -4603,11 +4422,7 @@
     ClassLoaderDataGraph::remember_new_clds(false);
 
     _timer.stop();
-    if (PrintCMSStatistics != 0) {
-      gclog_or_tty->print_cr(
-          "Finished unhandled CLD scanning work in %dth thread: %3.3f sec",
-          worker_id, _timer.seconds());
-    }
+    log_trace(gc, task)("Finished unhandled CLD scanning work in %dth thread: %3.3f sec", worker_id, _timer.seconds());
   }
 
   // ---------- dirty klass scanning ----------
@@ -4620,11 +4435,7 @@
     ClassLoaderDataGraph::classes_do(&remark_klass_closure);
 
     _timer.stop();
-    if (PrintCMSStatistics != 0) {
-      gclog_or_tty->print_cr(
-          "Finished dirty klass scanning work in %dth thread: %3.3f sec",
-          worker_id, _timer.seconds());
-    }
+    log_trace(gc, task)("Finished dirty klass scanning work in %dth thread: %3.3f sec", worker_id, _timer.seconds());
   }
 
   // We might have added oops to ClassLoaderData::_handles during the
@@ -4642,11 +4453,7 @@
   // "worker_id" is passed to select the task_queue for "worker_id"
   do_dirty_card_rescan_tasks(_cms_space, worker_id, &par_mrias_cl);
   _timer.stop();
-  if (PrintCMSStatistics != 0) {
-    gclog_or_tty->print_cr(
-      "Finished dirty card rescan work in %dth thread: %3.3f sec",
-      worker_id, _timer.seconds());
-  }
+  log_trace(gc, task)("Finished dirty card rescan work in %dth thread: %3.3f sec", worker_id, _timer.seconds());
 
   // ---------- steal work from other threads ...
   // ---------- ... and drain overflow list.
@@ -4654,11 +4461,7 @@
   _timer.start();
   do_work_steal(worker_id, &par_mrias_cl, _collector->hash_seed(worker_id));
   _timer.stop();
-  if (PrintCMSStatistics != 0) {
-    gclog_or_tty->print_cr(
-      "Finished work stealing in %dth thread: %3.3f sec",
-      worker_id, _timer.seconds());
-  }
+  log_trace(gc, task)("Finished work stealing in %dth thread: %3.3f sec", worker_id, _timer.seconds());
 }
 
 // Note that parameter "i" is not used.
@@ -4852,11 +4655,7 @@
         break;  // nirvana from the infinite cycle
     }
   }
-  NOT_PRODUCT(
-    if (PrintCMSStatistics != 0) {
-      gclog_or_tty->print("\n\t(%d: stole %d oops)", i, num_steals);
-    }
-  )
+  log_develop_trace(gc, task)("\t(%d: stole %d oops)", i, num_steals);
   assert(work_q->size() == 0 && _collector->overflow_list_is_empty(),
          "Else our work is not yet done");
 }
@@ -4953,9 +4752,7 @@
   }
   // We are all done; record the size of the _survivor_chunk_array
   _survivor_chunk_index = i; // exclusive: [0, i)
-  if (PrintCMSStatistics > 0) {
-    gclog_or_tty->print(" (Survivor:" SIZE_FORMAT "chunks) ", i);
-  }
+  log_trace(gc, survivor)(" (Survivor:" SIZE_FORMAT "chunks) ", i);
   // Verify that we used up all the recorded entries
   #ifdef ASSERT
     size_t total = 0;
@@ -4967,10 +4764,8 @@
     // Check that the merged array is in sorted order
     if (total > 0) {
       for (size_t i = 0; i < total - 1; i++) {
-        if (PrintCMSStatistics > 0) {
-          gclog_or_tty->print(" (chunk" SIZE_FORMAT ":" INTPTR_FORMAT ") ",
-                              i, p2i(_survivor_chunk_array[i]));
-        }
+        log_develop_trace(gc, survivor)(" (chunk" SIZE_FORMAT ":" INTPTR_FORMAT ") ",
+                                     i, p2i(_survivor_chunk_array[i]));
         assert(_survivor_chunk_array[i] < _survivor_chunk_array[i+1],
                "Not sorted");
       }
@@ -5104,7 +4899,7 @@
                               NULL,  // space is set further below
                               &_markBitMap, &_markStack, &mrias_cl);
   {
-    GCTraceTime t("grey object rescan", PrintGCDetails, false, _gc_timer_cm);
+    GCTraceTime(Trace, gc) t("Grey Object Rescan", _gc_timer_cm);
     // Iterate over the dirty cards, setting the corresponding bits in the
     // mod union table.
     {
@@ -5129,10 +4924,7 @@
       _modUnionTable.dirty_range_iterate_clear(cms_span,
                                                &markFromDirtyCardsClosure);
       verify_work_stacks_empty();
-      if (PrintCMSStatistics != 0) {
-        gclog_or_tty->print(" (re-scanned " SIZE_FORMAT " dirty cards in cms gen) ",
-          markFromDirtyCardsClosure.num_dirty_cards());
-      }
+      log_trace(gc)(" (re-scanned " SIZE_FORMAT " dirty cards in cms gen) ", markFromDirtyCardsClosure.num_dirty_cards());
     }
   }
   if (VerifyDuringGC &&
@@ -5141,7 +4933,7 @@
     Universe::verify();
   }
   {
-    GCTraceTime t("root rescan", PrintGCDetails, false, _gc_timer_cm);
+    GCTraceTime(Trace, gc) t("Root Rescan", _gc_timer_cm);
 
     verify_work_stacks_empty();
 
@@ -5163,7 +4955,7 @@
   }
 
   {
-    GCTraceTime t("visit unhandled CLDs", PrintGCDetails, false, _gc_timer_cm);
+    GCTraceTime(Trace, gc) t("Visit Unhandled CLDs", _gc_timer_cm);
 
     verify_work_stacks_empty();
 
@@ -5182,7 +4974,7 @@
   }
 
   {
-    GCTraceTime t("dirty klass scan", PrintGCDetails, false, _gc_timer_cm);
+    GCTraceTime(Trace, gc) t("Dirty Klass Scan", _gc_timer_cm);
 
     verify_work_stacks_empty();
 
@@ -5344,11 +5136,7 @@
       break;  // nirvana from the infinite cycle
     }
   }
-  NOT_PRODUCT(
-    if (PrintCMSStatistics != 0) {
-      gclog_or_tty->print("\n\t(%d: stole %d oops)", i, num_steals);
-    }
-  )
+  log_develop_trace(gc, task)("\t(%d: stole %d oops)", i, num_steals);
 }
 
 void CMSRefProcTaskExecutor::execute(ProcessTask& task)
@@ -5390,7 +5178,7 @@
                                 _span, &_markBitMap, &_markStack,
                                 &cmsKeepAliveClosure, false /* !preclean */);
   {
-    GCTraceTime t("weak refs processing", PrintGCDetails, false, _gc_timer_cm);
+    GCTraceTime(Debug, gc) t("Weak Refs Processing", _gc_timer_cm);
 
     ReferenceProcessorStats stats;
     if (rp->processing_is_mt()) {
@@ -5432,7 +5220,7 @@
 
   if (should_unload_classes()) {
     {
-      GCTraceTime t("class unloading", PrintGCDetails, false, _gc_timer_cm);
+      GCTraceTime(Debug, gc) t("Class Unloading", _gc_timer_cm);
 
       // Unload classes and purge the SystemDictionary.
       bool purged_class = SystemDictionary::do_unloading(&_is_alive_closure);
@@ -5445,13 +5233,13 @@
     }
 
     {
-      GCTraceTime t("scrub symbol table", PrintGCDetails, false, _gc_timer_cm);
+      GCTraceTime(Debug, gc) t("Scrub Symbol Table", _gc_timer_cm);
       // Clean up unreferenced symbols in symbol table.
       SymbolTable::unlink();
     }
 
     {
-      GCTraceTime t("scrub string table", PrintGCDetails, false, _gc_timer_cm);
+      GCTraceTime(Debug, gc) t("Scrub String Table", _gc_timer_cm);
       // Delete entries for dead interned strings.
       StringTable::unlink(&_is_alive_closure);
     }
@@ -5518,8 +5306,8 @@
   _intra_sweep_timer.reset();
   _intra_sweep_timer.start();
   {
-    TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
-    CMSPhaseAccounting pa(this, "sweep", !PrintGCDetails);
+    GCTraceCPUTime tcpu;
+    CMSPhaseAccounting pa(this, "Concurrent Sweep");
     // First sweep the old gen
     {
       CMSTokenSyncWithLocks ts(true, _cmsGen->freelistLock(),
@@ -5602,13 +5390,8 @@
   size_t largestOffset     = pointer_delta(largestAddr, minAddr);
   size_t nearLargestOffset =
     (size_t)((double)largestOffset * nearLargestPercent) - MinChunkSize;
-  if (PrintFLSStatistics != 0) {
-    gclog_or_tty->print_cr(
-      "CMS: Large Block: " PTR_FORMAT ";"
-      " Proximity: " PTR_FORMAT " -> " PTR_FORMAT,
-      p2i(largestAddr),
-      p2i(_cmsSpace->nearLargestChunk()), p2i(minAddr + nearLargestOffset));
-  }
+  log_debug(gc, freelist)("CMS: Large Block: " PTR_FORMAT "; Proximity: " PTR_FORMAT " -> " PTR_FORMAT,
+                          p2i(largestAddr), p2i(_cmsSpace->nearLargestChunk()), p2i(minAddr + nearLargestOffset));
   _cmsSpace->set_nearLargestChunk(minAddr + nearLargestOffset);
 }
 
@@ -5702,8 +5485,8 @@
 
   // Clear the mark bitmap (no grey objects to start with)
   // for the next cycle.
-  TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
-  CMSPhaseAccounting cmspa(this, "reset", !PrintGCDetails);
+  GCTraceCPUTime tcpu;
+  CMSPhaseAccounting cmspa(this, "Concurrent Reset");
 
   HeapWord* curAddr = _markBitMap.startWord();
   while (curAddr < _markBitMap.endWord()) {
@@ -5719,9 +5502,7 @@
       bitMapLock()->unlock();
       ConcurrentMarkSweepThread::desynchronize(true);
       stopTimer();
-      if (PrintCMSStatistics != 0) {
-        incrementYields();
-      }
+      incrementYields();
 
       // See the comment in coordinator_yield()
       for (unsigned i = 0; i < CMSYieldSleepCount &&
@@ -5758,25 +5539,20 @@
 }
 
 void CMSCollector::do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause) {
-  TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
-  GCTraceTime t(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, NULL);
+  GCTraceCPUTime tcpu;
   TraceCollectorStats tcs(counters());
 
   switch (op) {
     case CMS_op_checkpointRootsInitial: {
+      GCTraceTime(Info, gc) t("Pause Initial Mark", NULL, GCCause::_no_gc, true);
       SvcGCMarker sgcm(SvcGCMarker::OTHER);
       checkpointRootsInitial();
-      if (PrintGC) {
-        _cmsGen->printOccupancy("initial-mark");
-      }
       break;
     }
     case CMS_op_checkpointRootsFinal: {
+      GCTraceTime(Info, gc) t("Pause Remark", NULL, GCCause::_no_gc, true);
       SvcGCMarker sgcm(SvcGCMarker::OTHER);
       checkpointRootsFinal();
-      if (PrintGC) {
-        _cmsGen->printOccupancy("remark");
-      }
       break;
     }
     default:
@@ -5989,9 +5765,9 @@
 void CMSMarkStack::expand() {
   assert(_capacity <= MarkStackSizeMax, "stack bigger than permitted");
   if (_capacity == MarkStackSizeMax) {
-    if (_hit_limit++ == 0 && !CMSConcurrentMTEnabled && PrintGCDetails) {
+    if (_hit_limit++ == 0 && !CMSConcurrentMTEnabled) {
       // We print a warning message only once per CMS cycle.
-      gclog_or_tty->print_cr(" (benign) Hit CMSMarkStack max size limit");
+      log_debug(gc)(" (benign) Hit CMSMarkStack max size limit");
     }
     return;
   }
@@ -6011,12 +5787,11 @@
     _base = (oop*)(_virtual_space.low());
     _index = 0;
     _capacity = new_capacity;
-  } else if (_failed_double++ == 0 && !CMSConcurrentMTEnabled && PrintGCDetails) {
+  } else if (_failed_double++ == 0 && !CMSConcurrentMTEnabled) {
     // Failed to double capacity, continue;
     // we print a detail message only once per CMS cycle.
-    gclog_or_tty->print(" (benign) Failed to expand marking stack from " SIZE_FORMAT "K to "
-            SIZE_FORMAT "K",
-            _capacity / K, new_capacity / K);
+    log_debug(gc)(" (benign) Failed to expand marking stack from " SIZE_FORMAT "K to " SIZE_FORMAT "K",
+                        _capacity / K, new_capacity / K);
   }
 }
 
@@ -6093,8 +5868,10 @@
   if (_span.contains(addr)) {
     _verification_bm->mark(addr);
     if (!_cms_bm->isMarked(addr)) {
-      oop(addr)->print();
-      gclog_or_tty->print_cr(" (" INTPTR_FORMAT " should have been marked)", p2i(addr));
+      LogHandle(gc, verify) log;
+      ResourceMark rm;
+      oop(addr)->print_on(log.info_stream());
+      log.info(" (" INTPTR_FORMAT " should have been marked)", p2i(addr));
       fatal("... aborting");
     }
   }
@@ -6190,9 +5967,7 @@
   _freelistLock->unlock();
   ConcurrentMarkSweepThread::desynchronize(true);
   _collector->stopTimer();
-  if (PrintCMSStatistics != 0) {
-    _collector->incrementYields();
-  }
+  _collector->incrementYields();
 
   // See the comment in coordinator_yield()
   for (unsigned i = 0;
@@ -6348,9 +6123,7 @@
   _freelistLock->unlock();
   ConcurrentMarkSweepThread::desynchronize(true);
   _collector->stopTimer();
-  if (PrintCMSStatistics != 0) {
-    _collector->incrementYields();
-  }
+  _collector->incrementYields();
 
   // See the comment in coordinator_yield()
   for (unsigned i = 0; i < CMSYieldSleepCount &&
@@ -6417,9 +6190,7 @@
   _bit_map->lock()->unlock();
   ConcurrentMarkSweepThread::desynchronize(true);
   _collector->stopTimer();
-  if (PrintCMSStatistics != 0) {
-    _collector->incrementYields();
-  }
+  _collector->incrementYields();
 
   // See the comment in coordinator_yield()
   for (unsigned i = 0; i < CMSYieldSleepCount &&
@@ -6572,9 +6343,7 @@
   _bitMap->lock()->unlock();
   ConcurrentMarkSweepThread::desynchronize(true);
   _collector->stopTimer();
-  if (PrintCMSStatistics != 0) {
-    _collector->incrementYields();
-  }
+  _collector->incrementYields();
 
   // See the comment in coordinator_yield()
   for (unsigned i = 0; i < CMSYieldSleepCount &&
@@ -6880,17 +6649,15 @@
     // Oop lies in _span and isn't yet grey or black
     _verification_bm->mark(addr);            // now grey
     if (!_cms_bm->isMarked(addr)) {
-      oop(addr)->print();
-      gclog_or_tty->print_cr(" (" INTPTR_FORMAT " should have been marked)",
-                             p2i(addr));
+      LogHandle(gc, verify) log;
+      ResourceMark rm;
+      oop(addr)->print_on(log.info_stream());
+      log.info(" (" INTPTR_FORMAT " should have been marked)", p2i(addr));
       fatal("... aborting");
     }
 
     if (!_mark_stack->push(obj)) { // stack overflow
-      if (PrintCMSStatistics != 0) {
-        gclog_or_tty->print_cr("CMS marking stack overflow (benign) at "
-                               SIZE_FORMAT, _mark_stack->capacity());
-      }
+      log_trace(gc)("CMS marking stack overflow (benign) at " SIZE_FORMAT, _mark_stack->capacity());
       assert(_mark_stack->isFull(), "Else push should have succeeded");
       handle_stack_overflow(addr);
     }
@@ -6990,10 +6757,7 @@
         }
       )
       if (simulate_overflow || !_markStack->push(obj)) { // stack overflow
-        if (PrintCMSStatistics != 0) {
-          gclog_or_tty->print_cr("CMS marking stack overflow (benign) at "
-                                 SIZE_FORMAT, _markStack->capacity());
-        }
+        log_trace(gc)("CMS marking stack overflow (benign) at " SIZE_FORMAT, _markStack->capacity());
         assert(simulate_overflow || _markStack->isFull(), "Else push should have succeeded");
         handle_stack_overflow(addr);
       }
@@ -7042,10 +6806,7 @@
     if (simulate_overflow ||
         !(_work_queue->push(obj) || _overflow_stack->par_push(obj))) {
       // stack overflow
-      if (PrintCMSStatistics != 0) {
-        gclog_or_tty->print_cr("CMS marking stack overflow (benign) at "
-                               SIZE_FORMAT, _overflow_stack->capacity());
-      }
+      log_trace(gc)("CMS marking stack overflow (benign) at " SIZE_FORMAT, _overflow_stack->capacity());
       // We cannot assert that the overflow stack is full because
       // it may have been emptied since.
       assert(simulate_overflow ||
@@ -7207,9 +6968,7 @@
   ConcurrentMarkSweepThread::desynchronize(true);
 
   _collector->stopTimer();
-  if (PrintCMSStatistics != 0) {
-    _collector->incrementYields();
-  }
+  _collector->incrementYields();
 
   // See the comment in coordinator_yield()
   for (unsigned i = 0; i < CMSYieldSleepCount &&
@@ -7240,10 +6999,7 @@
   // However, that would be too strong in one case -- the last
   // partition ends at _unallocated_block which, in general, can be
   // an arbitrary boundary, not necessarily card aligned.
-  if (PrintCMSStatistics != 0) {
-    _num_dirty_cards +=
-         mr.word_size()/CardTableModRefBS::card_size_in_words;
-  }
+  _num_dirty_cards += mr.word_size()/CardTableModRefBS::card_size_in_words;
   _space->object_iterate_mem(mr, &_scan_cl);
 }
 
@@ -7276,10 +7032,8 @@
   )
   assert(_limit >= _sp->bottom() && _limit <= _sp->end(),
          "sweep _limit out of bounds");
-  if (CMSTraceSweeper) {
-    gclog_or_tty->print_cr("\n====================\nStarting new sweep with limit " PTR_FORMAT,
-                        p2i(_limit));
-  }
+  log_develop_trace(gc, sweep)("====================");
+  log_develop_trace(gc, sweep)("Starting new sweep with limit " PTR_FORMAT, p2i(_limit));
 }
 
 void SweepClosure::print_on(outputStream* st) const {
@@ -7306,42 +7060,32 @@
     print();
     ShouldNotReachHere();
   }
-  if (Verbose && PrintGC) {
-    gclog_or_tty->print("Collected " SIZE_FORMAT " objects, " SIZE_FORMAT " bytes",
-                        _numObjectsFreed, _numWordsFreed*sizeof(HeapWord));
-    gclog_or_tty->print_cr("\nLive " SIZE_FORMAT " objects,  "
-                           SIZE_FORMAT " bytes  "
-      "Already free " SIZE_FORMAT " objects, " SIZE_FORMAT " bytes",
-      _numObjectsLive, _numWordsLive*sizeof(HeapWord),
-      _numObjectsAlreadyFree, _numWordsAlreadyFree*sizeof(HeapWord));
-    size_t totalBytes = (_numWordsFreed + _numWordsLive + _numWordsAlreadyFree)
-                        * sizeof(HeapWord);
-    gclog_or_tty->print_cr("Total sweep: " SIZE_FORMAT " bytes", totalBytes);
-
-    if (PrintCMSStatistics && CMSVerifyReturnedBytes) {
-      size_t indexListReturnedBytes = _sp->sumIndexedFreeListArrayReturnedBytes();
-      size_t dict_returned_bytes = _sp->dictionary()->sum_dict_returned_bytes();
-      size_t returned_bytes = indexListReturnedBytes + dict_returned_bytes;
-      gclog_or_tty->print("Returned " SIZE_FORMAT " bytes", returned_bytes);
-      gclog_or_tty->print("   Indexed List Returned " SIZE_FORMAT " bytes",
-        indexListReturnedBytes);
-      gclog_or_tty->print_cr("        Dictionary Returned " SIZE_FORMAT " bytes",
-        dict_returned_bytes);
-    }
-  }
-  if (CMSTraceSweeper) {
-    gclog_or_tty->print_cr("end of sweep with _limit = " PTR_FORMAT "\n================",
-                           p2i(_limit));
-  }
+
+  if (log_is_enabled(Debug, gc, sweep)) {
+    log_debug(gc, sweep)("Collected " SIZE_FORMAT " objects, " SIZE_FORMAT " bytes",
+                         _numObjectsFreed, _numWordsFreed*sizeof(HeapWord));
+    log_debug(gc, sweep)("Live " SIZE_FORMAT " objects,  " SIZE_FORMAT " bytes  Already free " SIZE_FORMAT " objects, " SIZE_FORMAT " bytes",
+                         _numObjectsLive, _numWordsLive*sizeof(HeapWord), _numObjectsAlreadyFree, _numWordsAlreadyFree*sizeof(HeapWord));
+    size_t totalBytes = (_numWordsFreed + _numWordsLive + _numWordsAlreadyFree) * sizeof(HeapWord);
+    log_debug(gc, sweep)("Total sweep: " SIZE_FORMAT " bytes", totalBytes);
+  }
+
+  if (log_is_enabled(Trace, gc, sweep) && CMSVerifyReturnedBytes) {
+    size_t indexListReturnedBytes = _sp->sumIndexedFreeListArrayReturnedBytes();
+    size_t dict_returned_bytes = _sp->dictionary()->sum_dict_returned_bytes();
+    size_t returned_bytes = indexListReturnedBytes + dict_returned_bytes;
+    log_trace(gc, sweep)("Returned " SIZE_FORMAT " bytes   Indexed List Returned " SIZE_FORMAT " bytes        Dictionary Returned " SIZE_FORMAT " bytes",
+                         returned_bytes, indexListReturnedBytes, dict_returned_bytes);
+  }
+  log_develop_trace(gc, sweep)("end of sweep with _limit = " PTR_FORMAT, p2i(_limit));
+  log_develop_trace(gc, sweep)("================");
 }
 #endif  // PRODUCT
 
 void SweepClosure::initialize_free_range(HeapWord* freeFinger,
     bool freeRangeInFreeLists) {
-  if (CMSTraceSweeper) {
-    gclog_or_tty->print("---- Start free range at " PTR_FORMAT " with free block (%d)\n",
-               p2i(freeFinger), freeRangeInFreeLists);
-  }
+  log_develop_trace(gc, sweep)("---- Start free range at " PTR_FORMAT " with free block (%d)",
+                               p2i(freeFinger), freeRangeInFreeLists);
   assert(!inFreeRange(), "Trampling existing free range");
   set_inFreeRange(true);
   set_lastFreeRangeCoalesced(false);
@@ -7407,13 +7151,9 @@
              "freeFinger() " PTR_FORMAT " is out-of-bounds", p2i(freeFinger()));
       flush_cur_free_chunk(freeFinger(),
                            pointer_delta(addr, freeFinger()));
-      if (CMSTraceSweeper) {
-        gclog_or_tty->print("Sweep: last chunk: ");
-        gclog_or_tty->print("put_free_blk " PTR_FORMAT " (" SIZE_FORMAT ") "
-                   "[coalesced:%d]\n",
-                   p2i(freeFinger()), pointer_delta(addr, freeFinger()),
-                   lastFreeRangeCoalesced() ? 1 : 0);
-      }
+      log_develop_trace(gc, sweep)("Sweep: last chunk: put_free_blk " PTR_FORMAT " (" SIZE_FORMAT ") [coalesced:%d]",
+                                   p2i(freeFinger()), pointer_delta(addr, freeFinger()),
+                                   lastFreeRangeCoalesced() ? 1 : 0);
     }
 
     // help the iterator loop finish
@@ -7624,9 +7364,7 @@
     assert(_sp->verify_chunk_in_free_list(fc), "free chunk is not in free lists");
   }
 
-  if (CMSTraceSweeper) {
-    gclog_or_tty->print_cr("  -- pick up another chunk at " PTR_FORMAT " (" SIZE_FORMAT ")", p2i(fc), chunkSize);
-  }
+  log_develop_trace(gc, sweep)("  -- pick up another chunk at " PTR_FORMAT " (" SIZE_FORMAT ")", p2i(fc), chunkSize);
 
   HeapWord* const fc_addr = (HeapWord*) fc;
 
@@ -7727,16 +7465,12 @@
          p2i(eob), p2i(eob-1), p2i(_limit), p2i(_sp->bottom()), p2i(_sp->end()), p2i(fc), chunk_size);
   if (eob >= _limit) {
     assert(eob == _limit || fc->is_free(), "Only a free chunk should allow us to cross over the limit");
-    if (CMSTraceSweeper) {
-      gclog_or_tty->print_cr("_limit " PTR_FORMAT " reached or crossed by block "
-                             "[" PTR_FORMAT "," PTR_FORMAT ") in space "
-                             "[" PTR_FORMAT "," PTR_FORMAT ")",
-                             p2i(_limit), p2i(fc), p2i(eob), p2i(_sp->bottom()), p2i(_sp->end()));
-    }
+    log_develop_trace(gc, sweep)("_limit " PTR_FORMAT " reached or crossed by block "
+                                 "[" PTR_FORMAT "," PTR_FORMAT ") in space "
+                                 "[" PTR_FORMAT "," PTR_FORMAT ")",
+                                 p2i(_limit), p2i(fc), p2i(eob), p2i(_sp->bottom()), p2i(_sp->end()));
     // Return the storage we are tracking back into the free lists.
-    if (CMSTraceSweeper) {
-      gclog_or_tty->print_cr("Flushing ... ");
-    }
+    log_develop_trace(gc, sweep)("Flushing ... ");
     assert(freeFinger() < eob, "Error");
     flush_cur_free_chunk( freeFinger(), pointer_delta(eob, freeFinger()));
   }
@@ -7753,10 +7487,7 @@
       assert(!_sp->verify_chunk_in_free_list(fc),
              "chunk should not be in free lists yet");
     }
-    if (CMSTraceSweeper) {
-      gclog_or_tty->print_cr(" -- add free block " PTR_FORMAT " (" SIZE_FORMAT ") to free lists",
-                    p2i(chunk), size);
-    }
+    log_develop_trace(gc, sweep)(" -- add free block " PTR_FORMAT " (" SIZE_FORMAT ") to free lists", p2i(chunk), size);
     // A new free range is going to be starting.  The current
     // free range has not been added to the free lists yet or
     // was removed so add it back.
@@ -7767,8 +7498,8 @@
     }
     _sp->addChunkAndRepairOffsetTable(chunk, size,
             lastFreeRangeCoalesced());
-  } else if (CMSTraceSweeper) {
-    gclog_or_tty->print_cr("Already in free list: nothing to flush");
+  } else {
+    log_develop_trace(gc, sweep)("Already in free list: nothing to flush");
   }
   set_inFreeRange(false);
   set_freeRangeInFreeLists(false);
@@ -7799,9 +7530,7 @@
   _freelistLock->unlock();
   ConcurrentMarkSweepThread::desynchronize(true);
   _collector->stopTimer();
-  if (PrintCMSStatistics != 0) {
-    _collector->incrementYields();
-  }
+  _collector->incrementYields();
 
   // See the comment in coordinator_yield()
   for (unsigned i = 0; i < CMSYieldSleepCount &&
@@ -7826,10 +7555,8 @@
 #endif
 
 void SweepClosure::print_free_block_coalesced(FreeChunk* fc) const {
-  if (CMSTraceSweeper) {
-    gclog_or_tty->print_cr("Sweep:coal_free_blk " PTR_FORMAT " (" SIZE_FORMAT ")",
-                           p2i(fc), fc->size());
-  }
+  log_develop_trace(gc, sweep)("Sweep:coal_free_blk " PTR_FORMAT " (" SIZE_FORMAT ")",
+                               p2i(fc), fc->size());
 }
 
 // CMSIsAliveClosure
--- a/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -35,6 +35,7 @@
 #include "gc/shared/generationCounters.hpp"
 #include "gc/shared/space.hpp"
 #include "gc/shared/taskqueue.hpp"
+#include "logging/log.hpp"
 #include "memory/freeBlockDictionary.hpp"
 #include "memory/iterator.hpp"
 #include "memory/virtualspace.hpp"
@@ -308,9 +309,8 @@
 
   void reset() {
     _index = 0;
-    if (_overflows > 0 && PrintCMSStatistics > 1) {
-      warning("CMS: ChunkArray[" SIZE_FORMAT "] overflowed " SIZE_FORMAT " times",
-              _capacity, _overflows);
+    if (_overflows > 0) {
+      log_trace(gc)("CMS: ChunkArray[" SIZE_FORMAT "] overflowed " SIZE_FORMAT " times", _capacity, _overflows);
     }
     _overflows = 0;
   }
@@ -451,7 +451,7 @@
 
   // Debugging.
   void print_on(outputStream* st) const PRODUCT_RETURN;
-  void print() const { print_on(gclog_or_tty); }
+  void print() const { print_on(tty); }
 };
 
 // A closure related to weak references processing which
@@ -935,7 +935,7 @@
   void    startTimer() { assert(!_timer.is_active(), "Error"); _timer.start();   }
   void    stopTimer()  { assert( _timer.is_active(), "Error"); _timer.stop();    }
   void    resetTimer() { assert(!_timer.is_active(), "Error"); _timer.reset();   }
-  double  timerValue() { assert(!_timer.is_active(), "Error"); return _timer.seconds(); }
+  jlong   timerTicks() { assert(!_timer.is_active(), "Error"); return _timer.ticks(); }
 
   int  yields()          { return _numYields; }
   void resetYields()     { _numYields = 0;    }
@@ -961,7 +961,7 @@
 
   // Debugging
   void verify();
-  bool verify_after_remark(bool silent = VerifySilently);
+  bool verify_after_remark();
   void verify_ok_to_terminate() const PRODUCT_RETURN;
   void verify_work_stacks_empty() const PRODUCT_RETURN;
   void verify_overflow_empty() const PRODUCT_RETURN;
@@ -1234,7 +1234,6 @@
   const char* name() const;
   virtual const char* short_name() const { return "CMS"; }
   void        print() const;
-  void printOccupancy(const char* s);
 
   // Resize the generation after a compacting GC.  The
   // generation can be treated as a contiguous space
--- a/src/share/vm/gc/cms/parNewGeneration.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/cms/parNewGeneration.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -34,7 +34,7 @@
 #include "gc/shared/gcHeapSummary.hpp"
 #include "gc/shared/gcTimer.hpp"
 #include "gc/shared/gcTrace.hpp"
-#include "gc/shared/gcTraceTime.hpp"
+#include "gc/shared/gcTraceTime.inline.hpp"
 #include "gc/shared/genCollectedHeap.hpp"
 #include "gc/shared/genOopClosures.inline.hpp"
 #include "gc/shared/generation.hpp"
@@ -45,6 +45,7 @@
 #include "gc/shared/strongRootsScope.hpp"
 #include "gc/shared/taskqueue.inline.hpp"
 #include "gc/shared/workgroup.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/objArrayOop.hpp"
 #include "oops/oop.inline.hpp"
@@ -270,9 +271,9 @@
 }
 
 void ParScanThreadState::print_promotion_failure_size() {
-  if (_promotion_failed_info.has_failed() && PrintPromotionFailure) {
-    gclog_or_tty->print(" (%d: promotion failure size = " SIZE_FORMAT ") ",
-                        _thread_num, _promotion_failed_info.first_size());
+  if (_promotion_failed_info.has_failed()) {
+    log_trace(gc, promotion)(" (%d: promotion failure size = " SIZE_FORMAT ") ",
+                             _thread_num, _promotion_failed_info.first_size());
   }
 }
 
@@ -298,11 +299,11 @@
 
   #if TASKQUEUE_STATS
   static void
-    print_termination_stats_hdr(outputStream* const st = gclog_or_tty);
-  void print_termination_stats(outputStream* const st = gclog_or_tty);
+    print_termination_stats_hdr(outputStream* const st);
+  void print_termination_stats();
   static void
-    print_taskqueue_stats_hdr(outputStream* const st = gclog_or_tty);
-  void print_taskqueue_stats(outputStream* const st = gclog_or_tty);
+    print_taskqueue_stats_hdr(outputStream* const st);
+  void print_taskqueue_stats();
   void reset_stats();
   #endif // TASKQUEUE_STATS
 
@@ -383,7 +384,15 @@
   st->print_raw_cr("--- --------- --------- ------ --------- ------ --------");
 }
 
-void ParScanThreadStateSet::print_termination_stats(outputStream* const st) {
+void ParScanThreadStateSet::print_termination_stats() {
+  LogHandle(gc, task, stats) log;
+  if (!log.is_debug()) {
+    return;
+  }
+
+  ResourceMark rm;
+  outputStream* st = log.debug_stream();
+
   print_termination_stats_hdr(st);
 
   for (int i = 0; i < length(); ++i) {
@@ -404,7 +413,13 @@
   st->print_raw("--- "); TaskQueueStats::print_header(2, st); st->cr();
 }
 
-void ParScanThreadStateSet::print_taskqueue_stats(outputStream* const st) {
+void ParScanThreadStateSet::print_taskqueue_stats() {
+  if (!develop_log_is_enabled(Trace, gc, task, stats)) {
+    return;
+  }
+  LogHandle(gc, task, stats) log;
+  ResourceMark rm;
+  outputStream* st = log.trace_stream();
   print_taskqueue_stats_hdr(st);
 
   TaskQueueStats totals;
@@ -823,9 +838,7 @@
   _promo_failure_scan_stack.clear(true); // Clear cached segments.
 
   remove_forwarding_pointers();
-  if (PrintGCDetails) {
-    gclog_or_tty->print(" (promotion failed)");
-  }
+  log_info(gc, promotion)("Promotion failed");
   // All the spaces are in play for mark-sweep.
   swap_spaces();  // Make life simpler for CMS || rescan; see 6483690.
   from()->set_next_compaction_space(to());
@@ -882,9 +895,7 @@
     size_policy->minor_collection_begin();
   }
 
-  GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL);
-  // Capture heap used before collection (for printing).
-  size_t gch_prev_used = gch->used();
+  GCTraceTime(Trace, gc) t1("ParNew", NULL, gch->gc_cause());
 
   age_table()->clear();
   to()->clear(SpaceDecorator::Mangle);
@@ -990,12 +1001,8 @@
     plab_stats()->adjust_desired_plab_sz();
   }
 
-  if (PrintGC && !PrintGCDetails) {
-    gch->print_heap_change(gch_prev_used);
-  }
-
-  TASKQUEUE_STATS_ONLY(if (PrintTerminationStats) thread_state_set.print_termination_stats());
-  TASKQUEUE_STATS_ONLY(if (PrintTaskqueue) thread_state_set.print_taskqueue_stats());
+  TASKQUEUE_STATS_ONLY(thread_state_set.print_termination_stats());
+  TASKQUEUE_STATS_ONLY(thread_state_set.print_taskqueue_stats());
 
   if (UseAdaptiveSizePolicy) {
     size_policy->minor_collection_end(gch->gc_cause());
@@ -1150,11 +1157,9 @@
 
   // This code must come after the CAS test, or it will print incorrect
   // information.
-  if (TraceScavenge) {
-    gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
-       is_in_reserved(new_obj) ? "copying" : "tenuring",
-       new_obj->klass()->internal_name(), p2i(old), p2i(new_obj), new_obj->size());
-  }
+  log_develop_trace(gc, scavenge)("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
+                                  is_in_reserved(new_obj) ? "copying" : "tenuring",
+                                  new_obj->klass()->internal_name(), p2i(old), p2i(new_obj), new_obj->size());
 
   if (forward_ptr == NULL) {
     oop obj_to_push = new_obj;
@@ -1176,9 +1181,7 @@
     )
     if (simulate_overflow || !par_scan_state->work_queue()->push(obj_to_push)) {
       // Add stats for overflow pushes.
-      if (Verbose && PrintGCDetails) {
-        gclog_or_tty->print("queue overflow!\n");
-      }
+      log_develop_trace(gc)("Queue Overflow");
       push_on_overflow_list(old, par_scan_state);
       TASKQUEUE_STATS_ONLY(par_scan_state->taskqueue_stats().record_overflow(0));
     }
--- a/src/share/vm/gc/cms/parOopClosures.inline.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/cms/parOopClosures.inline.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -30,6 +30,7 @@
 #include "gc/shared/cardTableRS.hpp"
 #include "gc/shared/genCollectedHeap.hpp"
 #include "gc/shared/genOopClosures.inline.hpp"
+#include "logging/log.hpp"
 
 template <class T> inline void ParScanWeakRefClosure::do_oop_work(T* p) {
   assert (!oopDesc::is_null(*p), "null weak reference?");
@@ -108,11 +109,9 @@
       if (m->is_marked()) { // Contains forwarding pointer.
         new_obj = ParNewGeneration::real_forwardee(obj);
         oopDesc::encode_store_heap_oop_not_null(p, new_obj);
-        if (TraceScavenge) {
-          gclog_or_tty->print_cr("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
-             "forwarded ",
-             new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size());
-        }
+        log_develop_trace(gc, scavenge)("{%s %s ( " PTR_FORMAT " ) " PTR_FORMAT " -> " PTR_FORMAT " (%d)}",
+                                        "forwarded ",
+                                        new_obj->klass()->internal_name(), p2i(p), p2i((void *)obj), p2i((void *)new_obj), new_obj->size());
       } else {
         size_t obj_sz = obj->size_given_klass(objK);
         new_obj = _g->copy_to_survivor_space(_par_scan_state, obj, obj_sz, m);
--- a/src/share/vm/gc/cms/promotionInfo.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/cms/promotionInfo.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -132,7 +132,7 @@
   }
 
   void print_on(outputStream* st) const;
-  void print() const { print_on(gclog_or_tty); }
+  void print() const { print_on(tty); }
 };
 
 class PromotionInfo VALUE_OBJ_CLASS_SPEC {
--- a/src/share/vm/gc/cms/vmCMSOperations.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/cms/vmCMSOperations.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -28,7 +28,7 @@
 #include "gc/cms/vmCMSOperations.hpp"
 #include "gc/shared/gcLocker.inline.hpp"
 #include "gc/shared/gcTimer.hpp"
-#include "gc/shared/gcTraceTime.hpp"
+#include "gc/shared/gcTraceTime.inline.hpp"
 #include "gc/shared/isGCActiveMark.hpp"
 #include "runtime/interfaceSupport.hpp"
 #include "runtime/os.hpp"
@@ -58,7 +58,7 @@
 void VM_CMS_Operation::verify_before_gc() {
   if (VerifyBeforeGC &&
       GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
-    GCTraceTime tm("Verify Before", false, false, _collector->_gc_timer_cm);
+    GCTraceTime(Info, gc, verify) tm("Verify Before", _collector->_gc_timer_cm);
     HandleMark hm;
     FreelistLocker x(_collector);
     MutexLockerEx  y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag);
@@ -70,7 +70,7 @@
 void VM_CMS_Operation::verify_after_gc() {
   if (VerifyAfterGC &&
       GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) {
-    GCTraceTime tm("Verify After", false, false, _collector->_gc_timer_cm);
+    GCTraceTime(Info, gc, verify) tm("Verify After", _collector->_gc_timer_cm);
     HandleMark hm;
     FreelistLocker x(_collector);
     MutexLockerEx  y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag);
--- a/src/share/vm/gc/g1/collectionSetChooser.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/collectionSetChooser.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -26,7 +26,6 @@
 #include "gc/g1/collectionSetChooser.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1CollectorPolicy.hpp"
-#include "gc/g1/g1ErgoVerbose.hpp"
 #include "gc/shared/space.inline.hpp"
 #include "runtime/atomic.inline.hpp"
 
@@ -136,8 +135,8 @@
     assert(regions_at(i) != NULL, "Should be true by sorting!");
   }
 #endif // ASSERT
-  if (G1PrintRegionLivenessInfo) {
-    G1PrintRegionLivenessInfoClosure cl(gclog_or_tty, "Post-Sorting");
+  if (log_is_enabled(Trace, gc, liveness)) {
+    G1PrintRegionLivenessInfoClosure cl("Post-Sorting");
     for (uint i = 0; i < _end; ++i) {
       HeapRegion* r = regions_at(i);
       cl.doHeapRegion(r);
--- a/src/share/vm/gc/g1/concurrentG1RefineThread.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/concurrentG1RefineThread.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -28,6 +28,7 @@
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/suspendibleThreadSet.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/mutexLocker.hpp"
@@ -88,11 +89,8 @@
 void ConcurrentG1RefineThread::activate() {
   MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
   if (!is_primary()) {
-    if (G1TraceConcRefinement) {
-      DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
-      gclog_or_tty->print_cr("G1-Refine-activated worker %d, on threshold %d, current %d",
-                             _worker_id, _threshold, (int)dcqs.completed_buffers_num());
-    }
+    log_debug(gc, refine)("G1-Refine-activated worker %d, on threshold %d, current %d",
+                          _worker_id, _threshold, JavaThread::dirty_card_queue_set().completed_buffers_num());
     set_active(true);
   } else {
     DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
@@ -104,11 +102,8 @@
 void ConcurrentG1RefineThread::deactivate() {
   MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
   if (!is_primary()) {
-    if (G1TraceConcRefinement) {
-      DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
-      gclog_or_tty->print_cr("G1-Refine-deactivated worker %d, off threshold %d, current %d",
-                             _worker_id, _deactivation_threshold, (int)dcqs.completed_buffers_num());
-    }
+    log_debug(gc, refine)("G1-Refine-deactivated worker %d, off threshold %d, current %d",
+                          _worker_id, _deactivation_threshold, JavaThread::dirty_card_queue_set().completed_buffers_num());
     set_active(false);
   } else {
     DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
@@ -174,9 +169,7 @@
     }
   }
 
-  if (G1TraceConcRefinement) {
-    gclog_or_tty->print_cr("G1-Refine-stop");
-  }
+  log_debug(gc, refine)("G1-Refine-stop");
 }
 
 void ConcurrentG1RefineThread::stop() {
@@ -199,4 +192,4 @@
 void ConcurrentG1RefineThread::stop_service() {
   MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
   _monitor->notify();
-}
\ No newline at end of file
+}
--- a/src/share/vm/gc/g1/concurrentMark.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/concurrentMark.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -31,8 +31,6 @@
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1CollectorState.hpp"
-#include "gc/g1/g1ErgoVerbose.hpp"
-#include "gc/g1/g1Log.hpp"
 #include "gc/g1/g1OopClosures.inline.hpp"
 #include "gc/g1/g1RemSet.hpp"
 #include "gc/g1/g1StringDedup.hpp"
@@ -44,12 +42,13 @@
 #include "gc/shared/gcId.hpp"
 #include "gc/shared/gcTimer.hpp"
 #include "gc/shared/gcTrace.hpp"
-#include "gc/shared/gcTraceTime.hpp"
+#include "gc/shared/gcTraceTime.inline.hpp"
 #include "gc/shared/genOopClosures.inline.hpp"
 #include "gc/shared/referencePolicy.hpp"
 #include "gc/shared/strongRootsScope.hpp"
 #include "gc/shared/taskqueue.inline.hpp"
 #include "gc/shared/vmGCOperations.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/oop.inline.hpp"
@@ -232,9 +231,7 @@
   // Clear expansion flag
   _should_expand = false;
   if (_capacity == (jint) MarkStackSizeMax) {
-    if (PrintGCDetails && Verbose) {
-      gclog_or_tty->print_cr(" (benign) Can't expand marking stack capacity, at max size limit");
-    }
+    log_trace(gc)("(benign) Can't expand marking stack capacity, at max size limit");
     return;
   }
   // Double capacity if possible
@@ -254,12 +251,9 @@
     _index = 0;
     _capacity = new_capacity;
   } else {
-    if (PrintGCDetails && Verbose) {
-      // Failed to double capacity, continue;
-      gclog_or_tty->print(" (benign) Failed to expand marking stack capacity from "
-                          SIZE_FORMAT "K to " SIZE_FORMAT "K",
-                          _capacity / K, new_capacity / K);
-    }
+    // Failed to double capacity, continue;
+    log_trace(gc)("(benign) Failed to expand marking stack capacity from " SIZE_FORMAT "K to " SIZE_FORMAT "K",
+                  _capacity / K, new_capacity / K);
   }
 }
 
@@ -848,10 +842,7 @@
       // marking.
       reset_marking_state(true /* clear_overflow */);
 
-      if (G1Log::fine()) {
-        gclog_or_tty->gclog_stamp();
-        gclog_or_tty->print_cr("[GC concurrent-mark-reset-for-overflow]");
-      }
+      log_info(gc)("Concurrent Mark reset for overflow");
     }
   }
 
@@ -987,8 +978,6 @@
 };
 
 void ConcurrentMark::scanRootRegions() {
-  double scan_start = os::elapsedTime();
-
   // Start of concurrent marking.
   ClassLoaderDataGraph::clear_claimed_marks();
 
@@ -996,10 +985,7 @@
   // at least one root region to scan. So, if it's false, we
   // should not attempt to do any further work.
   if (root_regions()->scan_in_progress()) {
-    if (G1Log::fine()) {
-      gclog_or_tty->gclog_stamp();
-      gclog_or_tty->print_cr("[GC concurrent-root-region-scan-start]");
-    }
+    GCTraceConcTime(Info, gc) tt("Concurrent Root Region Scan");
 
     _parallel_marking_threads = calc_parallel_marking_threads();
     assert(parallel_marking_threads() <= max_parallel_marking_threads(),
@@ -1010,11 +996,6 @@
     _parallel_workers->set_active_workers(active_workers);
     _parallel_workers->run_task(&task);
 
-    if (G1Log::fine()) {
-      gclog_or_tty->gclog_stamp();
-      gclog_or_tty->print_cr("[GC concurrent-root-region-scan-end, %1.7lf secs]", os::elapsedTime() - scan_start);
-    }
-
     // It's possible that has_aborted() is true here without actually
     // aborting the survivor scan earlier. This is OK as it's
     // mainly used for sanity checking.
@@ -1049,22 +1030,6 @@
   print_stats();
 }
 
-// Helper class to get rid of some boilerplate code.
-class G1CMTraceTime : public StackObj {
-  GCTraceTimeImpl _gc_trace_time;
-  static bool doit_and_prepend(bool doit) {
-    if (doit) {
-      gclog_or_tty->put(' ');
-    }
-    return doit;
-  }
-
- public:
-  G1CMTraceTime(const char* title, bool doit)
-    : _gc_trace_time(title, doit_and_prepend(doit), false, G1CollectedHeap::heap()->gc_timer_cm()) {
-  }
-};
-
 void ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) {
   // world is stopped at this checkpoint
   assert(SafepointSynchronize::is_at_safepoint(),
@@ -1083,8 +1048,7 @@
   if (VerifyDuringGC) {
     HandleMark hm;  // handle scope
     g1h->prepare_for_verify();
-    Universe::verify(VerifyOption_G1UsePrevMarking,
-                     " VerifyDuringGC:(before)");
+    Universe::verify(VerifyOption_G1UsePrevMarking, "During GC (before)");
   }
   g1h->check_bitmaps("Remark Start");
 
@@ -1102,16 +1066,13 @@
   if (has_overflown()) {
     // Oops.  We overflowed.  Restart concurrent marking.
     _restart_for_overflow = true;
-    if (G1TraceMarkStackOverflow) {
-      gclog_or_tty->print_cr("\nRemark led to restart for overflow.");
-    }
+    log_develop_trace(gc)("Remark led to restart for overflow.");
 
     // Verify the heap w.r.t. the previous marking bitmap.
     if (VerifyDuringGC) {
       HandleMark hm;  // handle scope
       g1h->prepare_for_verify();
-      Universe::verify(VerifyOption_G1UsePrevMarking,
-                       " VerifyDuringGC:(overflow)");
+      Universe::verify(VerifyOption_G1UsePrevMarking, "During GC (overflow)");
     }
 
     // Clear the marking state because we will be restarting
@@ -1119,7 +1080,7 @@
     reset_marking_state();
   } else {
     {
-      G1CMTraceTime trace("GC aggregate-data", G1Log::finer());
+      GCTraceTime(Debug, gc) trace("GC Aggregate Data", g1h->gc_timer_cm());
 
       // Aggregate the per-task counting data that we have accumulated
       // while marking.
@@ -1136,8 +1097,7 @@
     if (VerifyDuringGC) {
       HandleMark hm;  // handle scope
       g1h->prepare_for_verify();
-      Universe::verify(VerifyOption_G1UseNextMarking,
-                       " VerifyDuringGC:(after)");
+      Universe::verify(VerifyOption_G1UseNextMarking, "During GC (after)");
     }
     g1h->check_bitmaps("Remark End");
     assert(!restart_for_overflow(), "sanity");
@@ -1656,8 +1616,7 @@
   if (VerifyDuringGC) {
     HandleMark hm;  // handle scope
     g1h->prepare_for_verify();
-    Universe::verify(VerifyOption_G1UsePrevMarking,
-                     " VerifyDuringGC:(before)");
+    Universe::verify(VerifyOption_G1UsePrevMarking, "During GC (before)");
   }
   g1h->check_bitmaps("Cleanup Start");
 
@@ -1699,8 +1658,8 @@
   double this_final_counting_time = (count_end - start);
   _total_counting_time += this_final_counting_time;
 
-  if (G1PrintRegionLivenessInfo) {
-    G1PrintRegionLivenessInfoClosure cl(gclog_or_tty, "Post-Marking");
+  if (log_is_enabled(Trace, gc, liveness)) {
+    G1PrintRegionLivenessInfoClosure cl("Post-Marking");
     _g1h->heap_region_iterate(&cl);
   }
 
@@ -1743,10 +1702,6 @@
   double end = os::elapsedTime();
   _cleanup_times.add((end - start) * 1000.0);
 
-  if (G1Log::fine()) {
-    g1h->g1_policy()->print_heap_transition(start_used_bytes);
-  }
-
   // Clean up will have freed any regions completely full of garbage.
   // Update the soft reference policy with the new heap occupancy.
   Universe::update_heap_info_at_gc();
@@ -1754,8 +1709,7 @@
   if (VerifyDuringGC) {
     HandleMark hm;  // handle scope
     g1h->prepare_for_verify();
-    Universe::verify(VerifyOption_G1UsePrevMarking,
-                     " VerifyDuringGC:(after)");
+    Universe::verify(VerifyOption_G1UsePrevMarking, "During GC (after)");
   }
 
   g1h->check_bitmaps("Cleanup End");
@@ -1788,11 +1742,9 @@
   _cleanup_list.verify_optional();
   FreeRegionList tmp_free_list("Tmp Free List");
 
-  if (G1ConcRegionFreeingVerbose) {
-    gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : "
-                           "cleanup list has %u entries",
-                           _cleanup_list.length());
-  }
+  log_develop_trace(gc, freelist)("G1ConcRegionFreeing [complete cleanup] : "
+                                  "cleanup list has %u entries",
+                                  _cleanup_list.length());
 
   // No one else should be accessing the _cleanup_list at this point,
   // so it is not necessary to take any locks
@@ -1810,13 +1762,11 @@
     // region from the _cleanup_list).
     if ((tmp_free_list.length() % G1SecondaryFreeListAppendLength == 0) ||
         _cleanup_list.is_empty()) {
-      if (G1ConcRegionFreeingVerbose) {
-        gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : "
-                               "appending %u entries to the secondary_free_list, "
-                               "cleanup list still has %u entries",
-                               tmp_free_list.length(),
-                               _cleanup_list.length());
-      }
+      log_develop_trace(gc, freelist)("G1ConcRegionFreeing [complete cleanup] : "
+                                      "appending %u entries to the secondary_free_list, "
+                                      "cleanup list still has %u entries",
+                                      tmp_free_list.length(),
+                                      _cleanup_list.length());
 
       {
         MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);
@@ -2073,7 +2023,7 @@
   // Inner scope to exclude the cleaning of the string and symbol
   // tables from the displayed time.
   {
-    G1CMTraceTime t("GC ref-proc", G1Log::finer());
+    GCTraceTime(Debug, gc) trace("GC Ref Proc", g1h->gc_timer_cm());
 
     ReferenceProcessor* rp = g1h->ref_processor_cm();
 
@@ -2163,24 +2113,24 @@
 
   // Unload Klasses, String, Symbols, Code Cache, etc.
   {
-    G1CMTraceTime trace("Unloading", G1Log::finer());
+    GCTraceTime(Debug, gc) trace("Unloading", g1h->gc_timer_cm());
 
     if (ClassUnloadingWithConcurrentMark) {
       bool purged_classes;
 
       {
-        G1CMTraceTime trace("System Dictionary Unloading", G1Log::finest());
+        GCTraceTime(Trace, gc) trace("System Dictionary Unloading", g1h->gc_timer_cm());
         purged_classes = SystemDictionary::do_unloading(&g1_is_alive, false /* Defer klass cleaning */);
       }
 
       {
-        G1CMTraceTime trace("Parallel Unloading", G1Log::finest());
+        GCTraceTime(Trace, gc) trace("Parallel Unloading", g1h->gc_timer_cm());
         weakRefsWorkParallelPart(&g1_is_alive, purged_classes);
       }
     }
 
     if (G1StringDedup::is_enabled()) {
-      G1CMTraceTime trace("String Deduplication Unlink", G1Log::finest());
+      GCTraceTime(Trace, gc) trace("String Deduplication Unlink", g1h->gc_timer_cm());
       G1StringDedup::unlink(&g1_is_alive);
     }
   }
@@ -2301,7 +2251,7 @@
   HandleMark   hm;
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 
-  G1CMTraceTime trace("Finalize Marking", G1Log::finer());
+  GCTraceTime(Debug, gc) trace("Finalize Marking", g1h->gc_timer_cm());
 
   g1h->ensure_parsability(false);
 
@@ -2614,12 +2564,13 @@
 }
 
 void ConcurrentMark::print_stats() {
-  if (G1MarkingVerboseLevel > 0) {
-    gclog_or_tty->print_cr("---------------------------------------------------------------------");
-    for (size_t i = 0; i < _active_tasks; ++i) {
-      _tasks[i]->print_stats();
-      gclog_or_tty->print_cr("---------------------------------------------------------------------");
-    }
+  if (!log_is_enabled(Debug, gc, stats)) {
+    return;
+  }
+  log_debug(gc, stats)("---------------------------------------------------------------------");
+  for (size_t i = 0; i < _active_tasks; ++i) {
+    _tasks[i]->print_stats();
+    log_debug(gc, stats)("---------------------------------------------------------------------");
   }
 }
 
@@ -2663,16 +2614,21 @@
 
 static void print_ms_time_info(const char* prefix, const char* name,
                                NumberSeq& ns) {
-  gclog_or_tty->print_cr("%s%5d %12s: total time = %8.2f s (avg = %8.2f ms).",
+  log_trace(gc, marking)("%s%5d %12s: total time = %8.2f s (avg = %8.2f ms).",
                          prefix, ns.num(), name, ns.sum()/1000.0, ns.avg());
   if (ns.num() > 0) {
-    gclog_or_tty->print_cr("%s         [std. dev = %8.2f ms, max = %8.2f ms]",
+    log_trace(gc, marking)("%s         [std. dev = %8.2f ms, max = %8.2f ms]",
                            prefix, ns.sd(), ns.maximum());
   }
 }
 
 void ConcurrentMark::print_summary_info() {
-  gclog_or_tty->print_cr(" Concurrent marking:");
+  LogHandle(gc, marking) log;
+  if (!log.is_trace()) {
+    return;
+  }
+
+  log.trace(" Concurrent marking:");
   print_ms_time_info("  ", "init marks", _init_times);
   print_ms_time_info("  ", "remarks", _remark_times);
   {
@@ -2681,25 +2637,16 @@
 
   }
   print_ms_time_info("  ", "cleanups", _cleanup_times);
-  gclog_or_tty->print_cr("    Final counting total time = %8.2f s (avg = %8.2f ms).",
-                         _total_counting_time,
-                         (_cleanup_times.num() > 0 ? _total_counting_time * 1000.0 /
-                          (double)_cleanup_times.num()
-                         : 0.0));
+  log.trace("    Final counting total time = %8.2f s (avg = %8.2f ms).",
+            _total_counting_time, (_cleanup_times.num() > 0 ? _total_counting_time * 1000.0 / (double)_cleanup_times.num() : 0.0));
   if (G1ScrubRemSets) {
-    gclog_or_tty->print_cr("    RS scrub total time = %8.2f s (avg = %8.2f ms).",
-                           _total_rs_scrub_time,
-                           (_cleanup_times.num() > 0 ? _total_rs_scrub_time * 1000.0 /
-                            (double)_cleanup_times.num()
-                           : 0.0));
+    log.trace("    RS scrub total time = %8.2f s (avg = %8.2f ms).",
+              _total_rs_scrub_time, (_cleanup_times.num() > 0 ? _total_rs_scrub_time * 1000.0 / (double)_cleanup_times.num() : 0.0));
   }
-  gclog_or_tty->print_cr("  Total stop_world time = %8.2f s.",
-                         (_init_times.sum() + _remark_times.sum() +
-                          _cleanup_times.sum())/1000.0);
-  gclog_or_tty->print_cr("  Total concurrent time = %8.2f s "
-                "(%8.2f s marking).",
-                cmThread()->vtime_accum(),
-                cmThread()->vtime_mark_accum());
+  log.trace("  Total stop_world time = %8.2f s.",
+            (_init_times.sum() + _remark_times.sum() + _cleanup_times.sum())/1000.0);
+  log.trace("  Total concurrent time = %8.2f s (%8.2f s marking).",
+            cmThread()->vtime_accum(), cmThread()->vtime_mark_accum());
 }
 
 void ConcurrentMark::print_worker_threads_on(outputStream* st) const {
@@ -3079,15 +3026,15 @@
 }
 
 void CMTask::print_stats() {
-  gclog_or_tty->print_cr("Marking Stats, task = %u, calls = %d",
-                         _worker_id, _calls);
-  gclog_or_tty->print_cr("  Elapsed time = %1.2lfms, Termination time = %1.2lfms",
-                         _elapsed_time_ms, _termination_time_ms);
-  gclog_or_tty->print_cr("  Step Times (cum): num = %d, avg = %1.2lfms, sd = %1.2lfms",
-                         _step_times_ms.num(), _step_times_ms.avg(),
-                         _step_times_ms.sd());
-  gclog_or_tty->print_cr("                    max = %1.2lfms, total = %1.2lfms",
-                         _step_times_ms.maximum(), _step_times_ms.sum());
+  log_debug(gc, stats)("Marking Stats, task = %u, calls = %d",
+                       _worker_id, _calls);
+  log_debug(gc, stats)("  Elapsed time = %1.2lfms, Termination time = %1.2lfms",
+                       _elapsed_time_ms, _termination_time_ms);
+  log_debug(gc, stats)("  Step Times (cum): num = %d, avg = %1.2lfms, sd = %1.2lfms",
+                       _step_times_ms.num(), _step_times_ms.avg(),
+                       _step_times_ms.sd());
+  log_debug(gc, stats)("                    max = %1.2lfms, total = %1.2lfms",
+                       _step_times_ms.maximum(), _step_times_ms.sum());
 }
 
 bool ConcurrentMark::try_stealing(uint worker_id, int* hash_seed, oop& obj) {
@@ -3587,9 +3534,8 @@
 #define G1PPRL_SUM_MB_PERC_FORMAT(tag) G1PPRL_SUM_MB_FORMAT(tag) " / %1.2f %%"
 
 G1PrintRegionLivenessInfoClosure::
-G1PrintRegionLivenessInfoClosure(outputStream* out, const char* phase_name)
-  : _out(out),
-    _total_used_bytes(0), _total_capacity_bytes(0),
+G1PrintRegionLivenessInfoClosure(const char* phase_name)
+  : _total_used_bytes(0), _total_capacity_bytes(0),
     _total_prev_live_bytes(0), _total_next_live_bytes(0),
     _hum_used_bytes(0), _hum_capacity_bytes(0),
     _hum_prev_live_bytes(0), _hum_next_live_bytes(0),
@@ -3599,38 +3545,37 @@
   double now = os::elapsedTime();
 
   // Print the header of the output.
-  _out->cr();
-  _out->print_cr(G1PPRL_LINE_PREFIX" PHASE %s @ %1.3f", phase_name, now);
-  _out->print_cr(G1PPRL_LINE_PREFIX" HEAP"
-                 G1PPRL_SUM_ADDR_FORMAT("reserved")
-                 G1PPRL_SUM_BYTE_FORMAT("region-size"),
-                 p2i(g1_reserved.start()), p2i(g1_reserved.end()),
-                 HeapRegion::GrainBytes);
-  _out->print_cr(G1PPRL_LINE_PREFIX);
-  _out->print_cr(G1PPRL_LINE_PREFIX
-                G1PPRL_TYPE_H_FORMAT
-                G1PPRL_ADDR_BASE_H_FORMAT
-                G1PPRL_BYTE_H_FORMAT
-                G1PPRL_BYTE_H_FORMAT
-                G1PPRL_BYTE_H_FORMAT
-                G1PPRL_DOUBLE_H_FORMAT
-                G1PPRL_BYTE_H_FORMAT
-                G1PPRL_BYTE_H_FORMAT,
-                "type", "address-range",
-                "used", "prev-live", "next-live", "gc-eff",
-                "remset", "code-roots");
-  _out->print_cr(G1PPRL_LINE_PREFIX
-                G1PPRL_TYPE_H_FORMAT
-                G1PPRL_ADDR_BASE_H_FORMAT
-                G1PPRL_BYTE_H_FORMAT
-                G1PPRL_BYTE_H_FORMAT
-                G1PPRL_BYTE_H_FORMAT
-                G1PPRL_DOUBLE_H_FORMAT
-                G1PPRL_BYTE_H_FORMAT
-                G1PPRL_BYTE_H_FORMAT,
-                "", "",
-                "(bytes)", "(bytes)", "(bytes)", "(bytes/ms)",
-                "(bytes)", "(bytes)");
+  log_trace(gc, liveness)(G1PPRL_LINE_PREFIX" PHASE %s @ %1.3f", phase_name, now);
+  log_trace(gc, liveness)(G1PPRL_LINE_PREFIX" HEAP"
+                          G1PPRL_SUM_ADDR_FORMAT("reserved")
+                          G1PPRL_SUM_BYTE_FORMAT("region-size"),
+                          p2i(g1_reserved.start()), p2i(g1_reserved.end()),
+                          HeapRegion::GrainBytes);
+  log_trace(gc, liveness)(G1PPRL_LINE_PREFIX);
+  log_trace(gc, liveness)(G1PPRL_LINE_PREFIX
+                          G1PPRL_TYPE_H_FORMAT
+                          G1PPRL_ADDR_BASE_H_FORMAT
+                          G1PPRL_BYTE_H_FORMAT
+                          G1PPRL_BYTE_H_FORMAT
+                          G1PPRL_BYTE_H_FORMAT
+                          G1PPRL_DOUBLE_H_FORMAT
+                          G1PPRL_BYTE_H_FORMAT
+                          G1PPRL_BYTE_H_FORMAT,
+                          "type", "address-range",
+                          "used", "prev-live", "next-live", "gc-eff",
+                          "remset", "code-roots");
+  log_trace(gc, liveness)(G1PPRL_LINE_PREFIX
+                          G1PPRL_TYPE_H_FORMAT
+                          G1PPRL_ADDR_BASE_H_FORMAT
+                          G1PPRL_BYTE_H_FORMAT
+                          G1PPRL_BYTE_H_FORMAT
+                          G1PPRL_BYTE_H_FORMAT
+                          G1PPRL_DOUBLE_H_FORMAT
+                          G1PPRL_BYTE_H_FORMAT
+                          G1PPRL_BYTE_H_FORMAT,
+                          "", "",
+                          "(bytes)", "(bytes)", "(bytes)", "(bytes/ms)",
+                          "(bytes)", "(bytes)");
 }
 
 // It takes as a parameter a reference to one of the _hum_* fields, it
@@ -3701,18 +3646,18 @@
   _total_strong_code_roots_bytes += strong_code_roots_bytes;
 
   // Print a line for this particular region.
-  _out->print_cr(G1PPRL_LINE_PREFIX
-                 G1PPRL_TYPE_FORMAT
-                 G1PPRL_ADDR_BASE_FORMAT
-                 G1PPRL_BYTE_FORMAT
-                 G1PPRL_BYTE_FORMAT
-                 G1PPRL_BYTE_FORMAT
-                 G1PPRL_DOUBLE_FORMAT
-                 G1PPRL_BYTE_FORMAT
-                 G1PPRL_BYTE_FORMAT,
-                 type, p2i(bottom), p2i(end),
-                 used_bytes, prev_live_bytes, next_live_bytes, gc_eff,
-                 remset_bytes, strong_code_roots_bytes);
+  log_trace(gc, liveness)(G1PPRL_LINE_PREFIX
+                          G1PPRL_TYPE_FORMAT
+                          G1PPRL_ADDR_BASE_FORMAT
+                          G1PPRL_BYTE_FORMAT
+                          G1PPRL_BYTE_FORMAT
+                          G1PPRL_BYTE_FORMAT
+                          G1PPRL_DOUBLE_FORMAT
+                          G1PPRL_BYTE_FORMAT
+                          G1PPRL_BYTE_FORMAT,
+                          type, p2i(bottom), p2i(end),
+                          used_bytes, prev_live_bytes, next_live_bytes, gc_eff,
+                          remset_bytes, strong_code_roots_bytes);
 
   return false;
 }
@@ -3721,23 +3666,22 @@
   // add static memory usages to remembered set sizes
   _total_remset_bytes += HeapRegionRemSet::fl_mem_size() + HeapRegionRemSet::static_mem_size();
   // Print the footer of the output.
-  _out->print_cr(G1PPRL_LINE_PREFIX);
-  _out->print_cr(G1PPRL_LINE_PREFIX
-                 " SUMMARY"
-                 G1PPRL_SUM_MB_FORMAT("capacity")
-                 G1PPRL_SUM_MB_PERC_FORMAT("used")
-                 G1PPRL_SUM_MB_PERC_FORMAT("prev-live")
-                 G1PPRL_SUM_MB_PERC_FORMAT("next-live")
-                 G1PPRL_SUM_MB_FORMAT("remset")
-                 G1PPRL_SUM_MB_FORMAT("code-roots"),
-                 bytes_to_mb(_total_capacity_bytes),
-                 bytes_to_mb(_total_used_bytes),
-                 perc(_total_used_bytes, _total_capacity_bytes),
-                 bytes_to_mb(_total_prev_live_bytes),
-                 perc(_total_prev_live_bytes, _total_capacity_bytes),
-                 bytes_to_mb(_total_next_live_bytes),
-                 perc(_total_next_live_bytes, _total_capacity_bytes),
-                 bytes_to_mb(_total_remset_bytes),
-                 bytes_to_mb(_total_strong_code_roots_bytes));
-  _out->cr();
+  log_trace(gc, liveness)(G1PPRL_LINE_PREFIX);
+  log_trace(gc, liveness)(G1PPRL_LINE_PREFIX
+                         " SUMMARY"
+                         G1PPRL_SUM_MB_FORMAT("capacity")
+                         G1PPRL_SUM_MB_PERC_FORMAT("used")
+                         G1PPRL_SUM_MB_PERC_FORMAT("prev-live")
+                         G1PPRL_SUM_MB_PERC_FORMAT("next-live")
+                         G1PPRL_SUM_MB_FORMAT("remset")
+                         G1PPRL_SUM_MB_FORMAT("code-roots"),
+                         bytes_to_mb(_total_capacity_bytes),
+                         bytes_to_mb(_total_used_bytes),
+                         perc(_total_used_bytes, _total_capacity_bytes),
+                         bytes_to_mb(_total_prev_live_bytes),
+                         perc(_total_prev_live_bytes, _total_capacity_bytes),
+                         bytes_to_mb(_total_next_live_bytes),
+                         perc(_total_next_live_bytes, _total_capacity_bytes),
+                         bytes_to_mb(_total_remset_bytes),
+                         bytes_to_mb(_total_strong_code_roots_bytes));
 }
--- a/src/share/vm/gc/g1/concurrentMark.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/concurrentMark.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -978,8 +978,6 @@
 // after we sort the old regions at the end of the cleanup operation.
 class G1PrintRegionLivenessInfoClosure: public HeapRegionClosure {
 private:
-  outputStream* _out;
-
   // Accumulators for these values.
   size_t _total_used_bytes;
   size_t _total_capacity_bytes;
@@ -1024,7 +1022,7 @@
 public:
   // The header and footer are printed in the constructor and
   // destructor respectively.
-  G1PrintRegionLivenessInfoClosure(outputStream* out, const char* phase_name);
+  G1PrintRegionLivenessInfoClosure(const char* phase_name);
   virtual bool doHeapRegion(HeapRegion* r);
   ~G1PrintRegionLivenessInfoClosure();
 };
--- a/src/share/vm/gc/g1/concurrentMarkThread.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/concurrentMarkThread.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -26,12 +26,13 @@
 #include "gc/g1/concurrentMarkThread.inline.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1CollectorPolicy.hpp"
-#include "gc/g1/g1Log.hpp"
 #include "gc/g1/g1MMUTracker.hpp"
 #include "gc/g1/suspendibleThreadSet.hpp"
 #include "gc/g1/vm_operations_g1.hpp"
 #include "gc/shared/gcId.hpp"
 #include "gc/shared/gcTrace.hpp"
+#include "gc/shared/gcTraceTime.inline.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "runtime/vmThread.hpp"
 
@@ -78,20 +79,6 @@
   }
 };
 
-// We want to avoid that the logging from the concurrent thread is mixed
-// with the logging from a STW GC. So, if necessary join the STS to ensure
-// that the logging is done either before or after the STW logging.
-void ConcurrentMarkThread::cm_log(bool doit, bool join_sts, const char* fmt, ...) {
-  if (doit) {
-    SuspendibleThreadSetJoiner sts_joiner(join_sts);
-    va_list args;
-    va_start(args, fmt);
-    gclog_or_tty->gclog_stamp();
-    gclog_or_tty->vprint_cr(fmt, args);
-    va_end(args);
-  }
-}
-
 // Marking pauses can be scheduled flexibly, so we might delay marking to meet MMU.
 void ConcurrentMarkThread::delay_to_keep_mmu(G1CollectorPolicy* g1_policy, bool remark) {
   if (g1_policy->adaptive_young_list_length()) {
@@ -143,8 +130,11 @@
         _cm->scanRootRegions();
       }
 
-      double mark_start_sec = os::elapsedTime();
-      cm_log(G1Log::fine(), true, "[GC concurrent-mark-start]");
+      // It would be nice to use the GCTraceConcTime class here but
+      // the "end" logging is inside the loop and not at the end of
+      // a scope. Mimicking the same log output as GCTraceConcTime instead.
+      jlong mark_start = os::elapsed_counter();
+      log_info(gc)("Concurrent Mark (%.3fs)", TimeHelper::counter_to_seconds(mark_start));
 
       int iter = 0;
       do {
@@ -154,20 +144,22 @@
         }
 
         double mark_end_time = os::elapsedVTime();
-        double mark_end_sec = os::elapsedTime();
+        jlong mark_end = os::elapsed_counter();
         _vtime_mark_accum += (mark_end_time - cycle_start);
         if (!cm()->has_aborted()) {
           delay_to_keep_mmu(g1_policy, true /* remark */);
-
-          cm_log(G1Log::fine(), true, "[GC concurrent-mark-end, %1.7lf secs]", mark_end_sec - mark_start_sec);
+          log_info(gc)("Concurrent Mark (%.3fs, %.3fs) %.3fms",
+                       TimeHelper::counter_to_seconds(mark_start),
+                       TimeHelper::counter_to_seconds(mark_end),
+                       TimeHelper::counter_to_millis(mark_end - mark_start));
 
           CMCheckpointRootsFinalClosure final_cl(_cm);
-          VM_CGC_Operation op(&final_cl, "GC remark", true /* needs_pll */);
+          VM_CGC_Operation op(&final_cl, "Pause Remark", true /* needs_pll */);
           VMThread::execute(&op);
         }
         if (cm()->restart_for_overflow()) {
-          cm_log(G1TraceMarkStackOverflow, true, "Restarting conc marking because of MS overflow in remark (restart #%d).", iter);
-          cm_log(G1Log::fine(), true, "[GC concurrent-mark-restart-for-overflow]");
+          log_debug(gc)("Restarting conc marking because of MS overflow in remark (restart #%d).", iter);
+          log_info(gc)("Concurrent Mark restart for overflow");
         }
       } while (cm()->restart_for_overflow());
 
@@ -181,7 +173,7 @@
         delay_to_keep_mmu(g1_policy, false /* cleanup */);
 
         CMCleanUp cl_cl(_cm);
-        VM_CGC_Operation op(&cl_cl, "GC cleanup", false /* needs_pll */);
+        VM_CGC_Operation op(&cl_cl, "Pause Cleanup", false /* needs_pll */);
         VMThread::execute(&op);
       } else {
         // We don't want to update the marking status if a GC pause
@@ -201,8 +193,7 @@
         // place, it would wait for us to process the regions
         // reclaimed by cleanup.
 
-        double cleanup_start_sec = os::elapsedTime();
-        cm_log(G1Log::fine(), false, "[GC concurrent-cleanup-start]");
+        GCTraceConcTime(Info, gc) tt("Concurrent Cleanup");
 
         // Now do the concurrent cleanup operation.
         _cm->completeCleanup();
@@ -217,9 +208,6 @@
         // while it's trying to join the STS, which is conditional on
         // the GC workers finishing.
         g1h->reset_free_regions_coming();
-
-        double cleanup_end_sec = os::elapsedTime();
-        cm_log(G1Log::fine(), true, "[GC concurrent-cleanup-end, %1.7lf secs]", cleanup_end_sec - cleanup_start_sec);
       }
       guarantee(cm()->cleanup_list_is_empty(),
                 "at this point there should be no regions on the cleanup list");
@@ -253,7 +241,7 @@
         if (!cm()->has_aborted()) {
           g1_policy->record_concurrent_mark_cleanup_completed();
         } else {
-          cm_log(G1Log::fine(), false, "[GC concurrent-mark-abort]");
+          log_info(gc)("Concurrent Mark abort");
         }
       }
 
--- a/src/share/vm/gc/g1/concurrentMarkThread.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/concurrentMarkThread.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -40,7 +40,6 @@
   double _vtime_accum;  // Accumulated virtual time.
 
   double _vtime_mark_accum;
-  void cm_log(bool doit, bool join_sts, const char* fmt, ...) ATTRIBUTE_PRINTF(4, 5);
 
  public:
   virtual void run();
--- a/src/share/vm/gc/g1/g1BlockOffsetTable.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1BlockOffsetTable.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -27,6 +27,7 @@
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "gc/shared/space.hpp"
+#include "logging/log.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/java.hpp"
 #include "services/memTracker.hpp"
@@ -50,14 +51,9 @@
 
   storage->set_mapping_changed_listener(&_listener);
 
-  if (TraceBlockOffsetTable) {
-    gclog_or_tty->print_cr("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: ");
-    gclog_or_tty->print_cr("  "
-                  "  rs.base(): " PTR_FORMAT
-                  "  rs.size(): " SIZE_FORMAT
-                  "  rs end(): " PTR_FORMAT,
-                  p2i(bot_reserved.start()), bot_reserved.byte_size(), p2i(bot_reserved.end()));
-  }
+  log_trace(gc, bot)("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: ");
+  log_trace(gc, bot)("    rs.base(): " PTR_FORMAT "  rs.size(): " SIZE_FORMAT "  rs end(): " PTR_FORMAT,
+                     p2i(bot_reserved.start()), bot_reserved.byte_size(), p2i(bot_reserved.end()));
 }
 
 bool G1BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const {
--- a/src/share/vm/gc/g1/g1CollectedHeap.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1CollectedHeap.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -36,10 +36,8 @@
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1CollectorState.hpp"
-#include "gc/g1/g1ErgoVerbose.hpp"
 #include "gc/g1/g1EvacStats.inline.hpp"
 #include "gc/g1/g1GCPhaseTimes.hpp"
-#include "gc/g1/g1Log.hpp"
 #include "gc/g1/g1MarkSweep.hpp"
 #include "gc/g1/g1OopClosures.inline.hpp"
 #include "gc/g1/g1ParScanThreadState.inline.hpp"
@@ -59,11 +57,12 @@
 #include "gc/shared/gcLocker.inline.hpp"
 #include "gc/shared/gcTimer.hpp"
 #include "gc/shared/gcTrace.hpp"
-#include "gc/shared/gcTraceTime.hpp"
+#include "gc/shared/gcTraceTime.inline.hpp"
 #include "gc/shared/generationSpec.hpp"
 #include "gc/shared/isGCActiveMark.hpp"
 #include "gc/shared/referenceProcessor.hpp"
 #include "gc/shared/taskqueue.inline.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.hpp"
 #include "memory/iterator.hpp"
 #include "oops/oop.inline.hpp"
@@ -224,11 +223,9 @@
   MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);
   while (!_secondary_free_list.is_empty() || free_regions_coming()) {
     if (!_secondary_free_list.is_empty()) {
-      if (G1ConcRegionFreeingVerbose) {
-        gclog_or_tty->print_cr("G1ConcRegionFreeing [region alloc] : "
-                               "secondary_free_list has %u entries",
-                               _secondary_free_list.length());
-      }
+      log_develop_trace(gc, freelist)("G1ConcRegionFreeing [region alloc] : "
+                                      "secondary_free_list has %u entries",
+                                      _secondary_free_list.length());
       // It looks as if there are free regions available on the
       // secondary_free_list. Let's move them to the free_list and try
       // again to allocate from it.
@@ -237,11 +234,9 @@
       assert(_hrm.num_free_regions() > 0, "if the secondary_free_list was not "
              "empty we should have moved at least one entry to the free_list");
       HeapRegion* res = _hrm.allocate_free_region(is_old);
-      if (G1ConcRegionFreeingVerbose) {
-        gclog_or_tty->print_cr("G1ConcRegionFreeing [region alloc] : "
-                               "allocated " HR_FORMAT " from secondary_free_list",
-                               HR_FORMAT_PARAMS(res));
-      }
+      log_develop_trace(gc, freelist)("G1ConcRegionFreeing [region alloc] : "
+                                      "allocated " HR_FORMAT " from secondary_free_list",
+                                      HR_FORMAT_PARAMS(res));
       return res;
     }
 
@@ -251,10 +246,8 @@
     SecondaryFreeList_lock->wait(Mutex::_no_safepoint_check_flag);
   }
 
-  if (G1ConcRegionFreeingVerbose) {
-    gclog_or_tty->print_cr("G1ConcRegionFreeing [region alloc] : "
-                           "could not allocate from secondary_free_list");
-  }
+  log_develop_trace(gc, freelist)("G1ConcRegionFreeing [region alloc] : "
+                                  "could not allocate from secondary_free_list");
   return NULL;
 }
 
@@ -266,10 +259,8 @@
   HeapRegion* res;
   if (G1StressConcRegionFreeing) {
     if (!_secondary_free_list.is_empty()) {
-      if (G1ConcRegionFreeingVerbose) {
-        gclog_or_tty->print_cr("G1ConcRegionFreeing [region alloc] : "
-                               "forced to look at the secondary_free_list");
-      }
+      log_develop_trace(gc, freelist)("G1ConcRegionFreeing [region alloc] : "
+                                      "forced to look at the secondary_free_list");
       res = new_region_try_secondary_free_list(is_old);
       if (res != NULL) {
         return res;
@@ -280,10 +271,8 @@
   res = _hrm.allocate_free_region(is_old);
 
   if (res == NULL) {
-    if (G1ConcRegionFreeingVerbose) {
-      gclog_or_tty->print_cr("G1ConcRegionFreeing [region alloc] : "
-                             "res == NULL, trying the secondary_free_list");
-    }
+    log_develop_trace(gc, freelist)("G1ConcRegionFreeing [region alloc] : "
+                                    "res == NULL, trying the secondary_free_list");
     res = new_region_try_secondary_free_list(is_old);
   }
   if (res == NULL && do_expand && _expand_heap_after_alloc_failure) {
@@ -293,11 +282,9 @@
     // reconsider the use of _expand_heap_after_alloc_failure.
     assert(SafepointSynchronize::is_at_safepoint(), "invariant");
 
-    ergo_verbose1(ErgoHeapSizing,
-                  "attempt heap expansion",
-                  ergo_format_reason("region allocation request failed")
-                  ergo_format_byte("allocation request"),
-                  word_size * HeapWordSize);
+    log_debug(gc, ergo, heap)("Attempt heap expansion (region allocation request failed). Allocation request: " SIZE_FORMAT "B",
+                              word_size * HeapWordSize);
+
     if (expand(word_size * HeapWordSize)) {
       // Given that expand() succeeded in expanding the heap, and we
       // always expand the heap by an amount aligned to the heap
@@ -485,11 +472,9 @@
     if (first != G1_NO_HRM_INDEX) {
       // We found something. Make sure these regions are committed, i.e. expand
       // the heap. Alternatively we could do a defragmentation GC.
-      ergo_verbose1(ErgoHeapSizing,
-                    "attempt heap expansion",
-                    ergo_format_reason("humongous allocation request failed")
-                    ergo_format_byte("allocation request"),
-                    word_size * HeapWordSize);
+      log_debug(gc, ergo, heap)("Attempt heap expansion (humongous allocation request failed). Allocation request: " SIZE_FORMAT "B",
+                                    word_size * HeapWordSize);
+
 
       _hrm.expand_at(first, obj_regions);
       g1_policy()->record_new_heap_size(num_regions());
@@ -808,11 +793,9 @@
     }
     increase_used(word_size * HeapWordSize);
     if (commits != 0) {
-      ergo_verbose1(ErgoHeapSizing,
-                    "attempt heap expansion",
-                    ergo_format_reason("allocate archive regions")
-                    ergo_format_byte("total size"),
-                    HeapRegion::GrainWords * HeapWordSize * commits);
+      log_debug(gc, ergo, heap)("Attempt heap expansion (allocate archive regions). Total size: " SIZE_FORMAT "B",
+                                HeapRegion::GrainWords * HeapWordSize * commits);
+
     }
 
     // Mark each G1 region touched by the range as archive, add it to the old set,
@@ -993,11 +976,8 @@
   }
 
   if (uncommitted_regions != 0) {
-    ergo_verbose1(ErgoHeapSizing,
-                  "attempt heap shrinking",
-                  ergo_format_reason("uncommitted archive regions")
-                  ergo_format_byte("total size"),
-                  HeapRegion::GrainWords * HeapWordSize * uncommitted_regions);
+    log_debug(gc, ergo, heap)("Attempt heap shrinking (uncommitted archive regions). Total size: " SIZE_FORMAT "B",
+                              HeapRegion::GrainWords * HeapWordSize * uncommitted_regions);
   }
   decrease_used(size_used);
 }
@@ -1236,8 +1216,11 @@
 };
 
 void G1CollectedHeap::print_hrm_post_compaction() {
-  PostCompactionPrinterClosure cl(hr_printer());
-  heap_region_iterate(&cl);
+  if (_hr_printer.is_active()) {
+    PostCompactionPrinterClosure cl(hr_printer());
+    heap_region_iterate(&cl);
+  }
+
 }
 
 bool G1CollectedHeap::do_full_collection(bool explicit_gc,
@@ -1258,7 +1241,6 @@
   SvcGCMarker sgcm(SvcGCMarker::FULL);
   ResourceMark rm;
 
-  G1Log::update_level();
   print_heap_before_gc();
   trace_heap_before_gc(gc_tracer);
 
@@ -1276,10 +1258,10 @@
 
     // Timing
     assert(!GCCause::is_user_requested_gc(gc_cause()) || explicit_gc, "invariant");
-    TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
+    GCTraceCPUTime tcpu;
 
     {
-      GCTraceTime t(GCCauseString("Full GC", gc_cause()), G1Log::fine(), true, NULL);
+      GCTraceTime(Info, gc) tm("Pause Full", NULL, gc_cause(), true);
       TraceCollectorStats tcs(g1mm()->full_collection_counters());
       TraceMemoryManagerStats tms(true /* fullGC */, gc_cause());
 
@@ -1330,11 +1312,6 @@
       _allocator->abandon_gc_alloc_regions();
       g1_rem_set()->cleanupHRRS();
 
-      // We should call this after we retire any currently active alloc
-      // regions so that all the ALLOC / RETIRE events are generated
-      // before the start GC event.
-      _hr_printer.start_gc(true /* full */, (size_t) total_collections());
-
       // We may have added regions to the current incremental collection
       // set between the last GC or pause and now. We need to clear the
       // incremental collection set and then start rebuilding it afresh
@@ -1401,14 +1378,10 @@
 
       resize_if_necessary_after_full_collection();
 
-      if (_hr_printer.is_active()) {
-        // We should do this after we potentially resize the heap so
-        // that all the COMMIT / UNCOMMIT events are generated before
-        // the end GC event.
-
-        print_hrm_post_compaction();
-        _hr_printer.end_gc(true /* full */, (size_t) total_collections());
-      }
+      // We should do this after we potentially resize the heap so
+      // that all the COMMIT / UNCOMMIT events are generated before
+      // the compaction events.
+      print_hrm_post_compaction();
 
       G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache();
       if (hot_card_cache->use_cache()) {
@@ -1477,10 +1450,6 @@
 
       g1_policy()->record_full_collection_end();
 
-      if (G1Log::fine()) {
-        g1_policy()->print_heap_transition();
-      }
-
       // We must call G1MonitoringSupport::update_sizes() in the same scoping level
       // as an active TraceMemoryManagerStats object (i.e. before the destructor for the
       // TraceMemoryManagerStats is called) so that the G1 memory pools are updated
@@ -1490,9 +1459,7 @@
       gc_epilogue(true);
     }
 
-    if (G1Log::finer()) {
-      g1_policy()->print_detailed_heap_transition(true /* full */);
-    }
+    g1_policy()->print_detailed_heap_transition();
 
     print_heap_after_gc();
     trace_heap_after_gc(gc_tracer);
@@ -1570,30 +1537,22 @@
   if (capacity_after_gc < minimum_desired_capacity) {
     // Don't expand unless it's significant
     size_t expand_bytes = minimum_desired_capacity - capacity_after_gc;
-    ergo_verbose4(ErgoHeapSizing,
-                  "attempt heap expansion",
-                  ergo_format_reason("capacity lower than "
-                                     "min desired capacity after Full GC")
-                  ergo_format_byte("capacity")
-                  ergo_format_byte("occupancy")
-                  ergo_format_byte_perc("min desired capacity"),
-                  capacity_after_gc, used_after_gc,
-                  minimum_desired_capacity, (double) MinHeapFreeRatio);
+
+    log_debug(gc, ergo, heap)("Attempt heap expansion (capacity lower than min desired capacity after Full GC). "
+                              "Capacity: " SIZE_FORMAT "B occupancy: " SIZE_FORMAT "B min_desired_capacity: " SIZE_FORMAT "B (" UINTX_FORMAT " %%)",
+                              capacity_after_gc, used_after_gc, minimum_desired_capacity, MinHeapFreeRatio);
+
     expand(expand_bytes);
 
     // No expansion, now see if we want to shrink
   } else if (capacity_after_gc > maximum_desired_capacity) {
     // Capacity too large, compute shrinking size
     size_t shrink_bytes = capacity_after_gc - maximum_desired_capacity;
-    ergo_verbose4(ErgoHeapSizing,
-                  "attempt heap shrinking",
-                  ergo_format_reason("capacity higher than "
-                                     "max desired capacity after Full GC")
-                  ergo_format_byte("capacity")
-                  ergo_format_byte("occupancy")
-                  ergo_format_byte_perc("max desired capacity"),
-                  capacity_after_gc, used_after_gc,
-                  maximum_desired_capacity, (double) MaxHeapFreeRatio);
+
+    log_debug(gc, ergo, heap)("Attempt heap shrinking (capacity higher than max desired capacity after Full GC). "
+                              "Capacity: " SIZE_FORMAT "B occupancy: " SIZE_FORMAT "B min_desired_capacity: " SIZE_FORMAT "B (" UINTX_FORMAT " %%)",
+                              capacity_after_gc, used_after_gc, minimum_desired_capacity, MinHeapFreeRatio);
+
     shrink(shrink_bytes);
   }
 }
@@ -1699,11 +1658,10 @@
   verify_region_sets_optional();
 
   size_t expand_bytes = MAX2(word_size * HeapWordSize, MinHeapDeltaBytes);
-  ergo_verbose1(ErgoHeapSizing,
-                "attempt heap expansion",
-                ergo_format_reason("allocation request failed")
-                ergo_format_byte("allocation request"),
-                word_size * HeapWordSize);
+  log_debug(gc, ergo, heap)("Attempt heap expansion (allocation request failed). Allocation request: " SIZE_FORMAT "B",
+                            word_size * HeapWordSize);
+
+
   if (expand(expand_bytes)) {
     _hrm.verify_optional();
     verify_region_sets_optional();
@@ -1718,16 +1676,12 @@
   size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
   aligned_expand_bytes = align_size_up(aligned_expand_bytes,
                                        HeapRegion::GrainBytes);
-  ergo_verbose2(ErgoHeapSizing,
-                "expand the heap",
-                ergo_format_byte("requested expansion amount")
-                ergo_format_byte("attempted expansion amount"),
-                expand_bytes, aligned_expand_bytes);
+
+  log_debug(gc, ergo, heap)("Expand the heap. requested expansion amount:" SIZE_FORMAT "B expansion amount:" SIZE_FORMAT "B",
+                            expand_bytes, aligned_expand_bytes);
 
   if (is_maximal_no_gc()) {
-    ergo_verbose0(ErgoHeapSizing,
-                      "did not expand the heap",
-                      ergo_format_reason("heap already fully expanded"));
+    log_debug(gc, ergo, heap)("Did not expand the heap (heap already fully expanded)");
     return false;
   }
 
@@ -1745,9 +1699,8 @@
     assert(actual_expand_bytes <= aligned_expand_bytes, "post-condition");
     g1_policy()->record_new_heap_size(num_regions());
   } else {
-    ergo_verbose0(ErgoHeapSizing,
-                  "did not expand the heap",
-                  ergo_format_reason("heap expansion operation failed"));
+    log_debug(gc, ergo, heap)("Did not expand the heap (heap expansion operation failed)");
+
     // The expansion of the virtual storage space was unsuccessful.
     // Let's see if it was because we ran out of swap.
     if (G1ExitOnExpansionFailure &&
@@ -1769,18 +1722,13 @@
   uint num_regions_removed = _hrm.shrink_by(num_regions_to_remove);
   size_t shrunk_bytes = num_regions_removed * HeapRegion::GrainBytes;
 
-  ergo_verbose3(ErgoHeapSizing,
-                "shrink the heap",
-                ergo_format_byte("requested shrinking amount")
-                ergo_format_byte("aligned shrinking amount")
-                ergo_format_byte("attempted shrinking amount"),
-                shrink_bytes, aligned_shrink_bytes, shrunk_bytes);
+
+  log_debug(gc, ergo, heap)("Shrink the heap. requested shrinking amount: " SIZE_FORMAT "B aligned shrinking amount: " SIZE_FORMAT "B attempted shrinking amount: " SIZE_FORMAT "B",
+                            shrink_bytes, aligned_shrink_bytes, shrunk_bytes);
   if (num_regions_removed > 0) {
     g1_policy()->record_new_heap_size(num_regions());
   } else {
-    ergo_verbose0(ErgoHeapSizing,
-                  "did not shrink the heap",
-                  ergo_format_reason("heap shrinking operation failed"));
+    log_debug(gc, ergo, heap)("Did not expand the heap (heap shrinking operation failed)");
   }
 }
 
@@ -1892,8 +1840,8 @@
                                          translation_factor,
                                          mtGC);
   if (TracePageSizes) {
-    gclog_or_tty->print_cr("G1 '%s': pg_sz=" SIZE_FORMAT " base=" PTR_FORMAT " size=" SIZE_FORMAT " alignment=" SIZE_FORMAT " reqsize=" SIZE_FORMAT,
-                           description, preferred_page_size, p2i(rs.base()), rs.size(), rs.alignment(), size);
+    tty->print_cr("G1 '%s': pg_sz=" SIZE_FORMAT " base=" PTR_FORMAT " size=" SIZE_FORMAT " alignment=" SIZE_FORMAT " reqsize=" SIZE_FORMAT,
+                  description, preferred_page_size, p2i(rs.base()), rs.size(), rs.alignment(), size);
   }
   return result;
 }
@@ -1902,16 +1850,10 @@
   CollectedHeap::pre_initialize();
   os::enable_vtime();
 
-  G1Log::init();
-
   // Necessary to satisfy locking discipline assertions.
 
   MutexLocker x(Heap_lock);
 
-  // We have to initialize the printer before committing the heap, as
-  // it will be used then.
-  _hr_printer.set_active(G1PrintHeapRegions);
-
   // While there are no constraints in the GC code that HeapWordSize
   // be any particular value, there are multiple other areas in the
   // system which believe this to be true (e.g. oop->object_size in some
@@ -2104,7 +2046,7 @@
 
 void G1CollectedHeap::stop() {
   // Stop all concurrent threads. We do this to make sure these threads
-  // do not continue to execute and access resources (e.g. gclog_or_tty)
+  // do not continue to execute and access resources (e.g. logging)
   // that are destroyed during shutdown.
   _cg1r->stop();
   _cmThread->stop();
@@ -2221,9 +2163,8 @@
   virtual bool doHeapRegion(HeapRegion* hr) {
     unsigned region_gc_time_stamp = hr->get_gc_time_stamp();
     if (_gc_time_stamp != region_gc_time_stamp) {
-      gclog_or_tty->print_cr("Region " HR_FORMAT " has GC time stamp = %d, "
-                             "expected %d", HR_FORMAT_PARAMS(hr),
-                             region_gc_time_stamp, _gc_time_stamp);
+      log_info(gc, verify)("Region " HR_FORMAT " has GC time stamp = %d, expected %d", HR_FORMAT_PARAMS(hr),
+                           region_gc_time_stamp, _gc_time_stamp);
       _failures = true;
     }
     return false;
@@ -2816,12 +2757,13 @@
     if (!oopDesc::is_null(heap_oop)) {
       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
       if (_g1h->is_obj_dead_cond(obj, _vo)) {
-        gclog_or_tty->print_cr("Root location " PTR_FORMAT " "
-                               "points to dead obj " PTR_FORMAT, p2i(p), p2i(obj));
+        LogHandle(gc, verify) log;
+        log.info("Root location " PTR_FORMAT " points to dead obj " PTR_FORMAT, p2i(p), p2i(obj));
         if (_vo == VerifyOption_G1UseMarkWord) {
-          gclog_or_tty->print_cr("  Mark word: " INTPTR_FORMAT, (intptr_t)obj->mark());
+          log.info("  Mark word: " PTR_FORMAT, p2i(obj->mark()));
         }
-        obj->print_on(gclog_or_tty);
+        ResourceMark rm;
+        obj->print_on(log.info_stream());
         _failures = true;
       }
     }
@@ -2866,10 +2808,10 @@
       // Verify that the strong code root list for this region
       // contains the nmethod
       if (!hrrs->strong_code_roots_list_contains(_nm)) {
-        gclog_or_tty->print_cr("Code root location " PTR_FORMAT " "
-                               "from nmethod " PTR_FORMAT " not in strong "
-                               "code roots for region [" PTR_FORMAT "," PTR_FORMAT ")",
-                               p2i(p), p2i(_nm), p2i(hr->bottom()), p2i(hr->end()));
+        log_info(gc, verify)("Code root location " PTR_FORMAT " "
+                             "from nmethod " PTR_FORMAT " not in strong "
+                             "code roots for region [" PTR_FORMAT "," PTR_FORMAT ")",
+                             p2i(p), p2i(_nm), p2i(hr->bottom()), p2i(hr->end()));
         _failures = true;
       }
     }
@@ -3047,12 +2989,8 @@
         r->object_iterate(&not_dead_yet_cl);
         if (_vo != VerifyOption_G1UseNextMarking) {
           if (r->max_live_bytes() < not_dead_yet_cl.live_bytes()) {
-            gclog_or_tty->print_cr("[" PTR_FORMAT "," PTR_FORMAT "] "
-                                   "max_live_bytes " SIZE_FORMAT " "
-                                   "< calculated " SIZE_FORMAT,
-                                   p2i(r->bottom()), p2i(r->end()),
-                                   r->max_live_bytes(),
-                                 not_dead_yet_cl.live_bytes());
+            log_info(gc, verify)("[" PTR_FORMAT "," PTR_FORMAT "] max_live_bytes " SIZE_FORMAT " < calculated " SIZE_FORMAT,
+                                 p2i(r->bottom()), p2i(r->end()), r->max_live_bytes(), not_dead_yet_cl.live_bytes());
             _failures = true;
           }
         } else {
@@ -3100,85 +3038,75 @@
   }
 };
 
-void G1CollectedHeap::verify(bool silent, VerifyOption vo) {
-  if (SafepointSynchronize::is_at_safepoint()) {
-    assert(Thread::current()->is_VM_thread(),
-           "Expected to be executed serially by the VM thread at this point");
-
-    if (!silent) { gclog_or_tty->print("Roots "); }
-    VerifyRootsClosure rootsCl(vo);
-    VerifyKlassClosure klassCl(this, &rootsCl);
-    CLDToKlassAndOopClosure cldCl(&klassCl, &rootsCl, false);
-
-    // We apply the relevant closures to all the oops in the
-    // system dictionary, class loader data graph, the string table
-    // and the nmethods in the code cache.
-    G1VerifyCodeRootOopClosure codeRootsCl(this, &rootsCl, vo);
-    G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl);
-
-    {
-      G1RootProcessor root_processor(this, 1);
-      root_processor.process_all_roots(&rootsCl,
-                                       &cldCl,
-                                       &blobsCl);
+void G1CollectedHeap::verify(VerifyOption vo) {
+  if (!SafepointSynchronize::is_at_safepoint()) {
+    log_info(gc, verify)("Skipping verification. Not at safepoint.");
+  }
+
+  assert(Thread::current()->is_VM_thread(),
+         "Expected to be executed serially by the VM thread at this point");
+
+  log_debug(gc, verify)("Roots");
+  VerifyRootsClosure rootsCl(vo);
+  VerifyKlassClosure klassCl(this, &rootsCl);
+  CLDToKlassAndOopClosure cldCl(&klassCl, &rootsCl, false);
+
+  // We apply the relevant closures to all the oops in the
+  // system dictionary, class loader data graph, the string table
+  // and the nmethods in the code cache.
+  G1VerifyCodeRootOopClosure codeRootsCl(this, &rootsCl, vo);
+  G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl);
+
+  {
+    G1RootProcessor root_processor(this, 1);
+    root_processor.process_all_roots(&rootsCl,
+                                     &cldCl,
+                                     &blobsCl);
+  }
+
+  bool failures = rootsCl.failures() || codeRootsCl.failures();
+
+  if (vo != VerifyOption_G1UseMarkWord) {
+    // If we're verifying during a full GC then the region sets
+    // will have been torn down at the start of the GC. Therefore
+    // verifying the region sets will fail. So we only verify
+    // the region sets when not in a full GC.
+    log_debug(gc, verify)("HeapRegionSets");
+    verify_region_sets();
+  }
+
+  log_debug(gc, verify)("HeapRegions");
+  if (GCParallelVerificationEnabled && ParallelGCThreads > 1) {
+
+    G1ParVerifyTask task(this, vo);
+    workers()->run_task(&task);
+    if (task.failures()) {
+      failures = true;
     }
 
-    bool failures = rootsCl.failures() || codeRootsCl.failures();
-
-    if (vo != VerifyOption_G1UseMarkWord) {
-      // If we're verifying during a full GC then the region sets
-      // will have been torn down at the start of the GC. Therefore
-      // verifying the region sets will fail. So we only verify
-      // the region sets when not in a full GC.
-      if (!silent) { gclog_or_tty->print("HeapRegionSets "); }
-      verify_region_sets();
+  } else {
+    VerifyRegionClosure blk(false, vo);
+    heap_region_iterate(&blk);
+    if (blk.failures()) {
+      failures = true;
     }
-
-    if (!silent) { gclog_or_tty->print("HeapRegions "); }
-    if (GCParallelVerificationEnabled && ParallelGCThreads > 1) {
-
-      G1ParVerifyTask task(this, vo);
-      workers()->run_task(&task);
-      if (task.failures()) {
-        failures = true;
-      }
-
-    } else {
-      VerifyRegionClosure blk(false, vo);
-      heap_region_iterate(&blk);
-      if (blk.failures()) {
-        failures = true;
-      }
-    }
-
-    if (G1StringDedup::is_enabled()) {
-      if (!silent) gclog_or_tty->print("StrDedup ");
-      G1StringDedup::verify();
-    }
-
-    if (failures) {
-      gclog_or_tty->print_cr("Heap:");
-      // It helps to have the per-region information in the output to
-      // help us track down what went wrong. This is why we call
-      // print_extended_on() instead of print_on().
-      print_extended_on(gclog_or_tty);
-      gclog_or_tty->cr();
-      gclog_or_tty->flush();
-    }
-    guarantee(!failures, "there should not have been any failures");
-  } else {
-    if (!silent) {
-      gclog_or_tty->print("(SKIPPING Roots, HeapRegionSets, HeapRegions, RemSet");
-      if (G1StringDedup::is_enabled()) {
-        gclog_or_tty->print(", StrDedup");
-      }
-      gclog_or_tty->print(") ");
-    }
-  }
-}
-
-void G1CollectedHeap::verify(bool silent) {
-  verify(silent, VerifyOption_G1UsePrevMarking);
+  }
+
+  if (G1StringDedup::is_enabled()) {
+    log_debug(gc, verify)("StrDedup");
+    G1StringDedup::verify();
+  }
+
+  if (failures) {
+    log_info(gc, verify)("Heap after failed verification:");
+    // It helps to have the per-region information in the output to
+    // help us track down what went wrong. This is why we call
+    // print_extended_on() instead of print_on().
+    LogHandle(gc, verify) log;
+    ResourceMark rm;
+    print_extended_on(log.info_stream());
+  }
+  guarantee(!failures, "there should not have been any failures");
 }
 
 double G1CollectedHeap::verify(bool guard, const char* msg) {
@@ -3196,12 +3124,12 @@
 }
 
 void G1CollectedHeap::verify_before_gc() {
-  double verify_time_ms = verify(VerifyBeforeGC, " VerifyBeforeGC:");
+  double verify_time_ms = verify(VerifyBeforeGC, "Before GC");
   g1_policy()->phase_times()->record_verify_before_time_ms(verify_time_ms);
 }
 
 void G1CollectedHeap::verify_after_gc() {
-  double verify_time_ms = verify(VerifyAfterGC, " VerifyAfterGC:");
+  double verify_time_ms = verify(VerifyAfterGC, "After GC");
   g1_policy()->phase_times()->record_verify_after_time_ms(verify_time_ms);
 }
 
@@ -3311,12 +3239,8 @@
     // to that.
     g1_policy()->print_tracing_info();
   }
-  if (G1SummarizeRSetStats) {
-    g1_rem_set()->print_summary_info();
-  }
-  if (G1SummarizeConcMark) {
-    concurrent_mark()->print_summary_info();
-  }
+  g1_rem_set()->print_summary_info();
+  concurrent_mark()->print_summary_info();
   g1_policy()->print_yg_surv_rate_info();
 }
 
@@ -3334,28 +3258,27 @@
     size_t occupied = hrrs->occupied();
     _occupied_sum += occupied;
 
-    gclog_or_tty->print_cr("Printing RSet for region " HR_FORMAT,
-                           HR_FORMAT_PARAMS(r));
+    tty->print_cr("Printing RSet for region " HR_FORMAT, HR_FORMAT_PARAMS(r));
     if (occupied == 0) {
-      gclog_or_tty->print_cr("  RSet is empty");
+      tty->print_cr("  RSet is empty");
     } else {
       hrrs->print();
     }
-    gclog_or_tty->print_cr("----------");
+    tty->print_cr("----------");
     return false;
   }
 
   PrintRSetsClosure(const char* msg) : _msg(msg), _occupied_sum(0) {
-    gclog_or_tty->cr();
-    gclog_or_tty->print_cr("========================================");
-    gclog_or_tty->print_cr("%s", msg);
-    gclog_or_tty->cr();
+    tty->cr();
+    tty->print_cr("========================================");
+    tty->print_cr("%s", msg);
+    tty->cr();
   }
 
   ~PrintRSetsClosure() {
-    gclog_or_tty->print_cr("Occupied Sum: " SIZE_FORMAT, _occupied_sum);
-    gclog_or_tty->print_cr("========================================");
-    gclog_or_tty->cr();
+    tty->print_cr("Occupied Sum: " SIZE_FORMAT, _occupied_sum);
+    tty->print_cr("========================================");
+    tty->cr();
   }
 };
 
@@ -3413,20 +3336,12 @@
   accumulate_statistics_all_tlabs();
   ensure_parsability(true);
 
-  if (G1SummarizeRSetStats && (G1SummarizeRSetStatsPeriod > 0) &&
-      (total_collections() % G1SummarizeRSetStatsPeriod == 0)) {
-    g1_rem_set()->print_periodic_summary_info("Before GC RS summary");
-  }
+  g1_rem_set()->print_periodic_summary_info("Before GC RS summary", total_collections());
 }
 
 void G1CollectedHeap::gc_epilogue(bool full) {
-
-  if (G1SummarizeRSetStats &&
-      (G1SummarizeRSetStatsPeriod > 0) &&
-      // we are at the end of the GC. Total collections has already been increased.
-      ((total_collections() - 1) % G1SummarizeRSetStatsPeriod == 0)) {
-    g1_rem_set()->print_periodic_summary_info("After GC RS summary");
-  }
+  // we are at the end of the GC. Total collections has already been increased.
+  g1_rem_set()->print_periodic_summary_info("After GC RS summary", total_collections() - 1);
 
   // FIXME: what is this about?
   // I'm ignoring the "fill_newgen()" call if "alloc_event_enabled"
@@ -3672,7 +3587,14 @@
   st->print_raw("--- "); TaskQueueStats::print_header(2, st); st->cr();
 }
 
-void G1CollectedHeap::print_taskqueue_stats(outputStream* const st) const {
+void G1CollectedHeap::print_taskqueue_stats() const {
+  if (!develop_log_is_enabled(Trace, gc, task, stats)) {
+    return;
+  }
+  LogHandle(gc, task, stats) log;
+  ResourceMark rm;
+  outputStream* st = log.trace_stream();
+
   print_taskqueue_stats_hdr(st);
 
   TaskQueueStats totals;
@@ -3694,41 +3616,17 @@
 }
 #endif // TASKQUEUE_STATS
 
-void G1CollectedHeap::log_gc_header() {
-  if (!G1Log::fine()) {
-    return;
-  }
-
-  gclog_or_tty->gclog_stamp();
-
-  GCCauseString gc_cause_str = GCCauseString("GC pause", gc_cause())
-    .append(collector_state()->gcs_are_young() ? "(young)" : "(mixed)")
-    .append(collector_state()->during_initial_mark_pause() ? " (initial-mark)" : "");
-
-  gclog_or_tty->print("[%s", (const char*)gc_cause_str);
-}
-
-void G1CollectedHeap::log_gc_footer(double pause_time_sec) {
-  if (!G1Log::fine()) {
-    return;
-  }
-
-  if (G1Log::finer()) {
-    if (evacuation_failed()) {
-      gclog_or_tty->print(" (to-space exhausted)");
-    }
-    gclog_or_tty->print_cr(", %3.7f secs]", pause_time_sec);
-    g1_policy()->print_phases(pause_time_sec);
-    g1_policy()->print_detailed_heap_transition();
-  } else {
-    if (evacuation_failed()) {
-      gclog_or_tty->print("--");
-    }
-    g1_policy()->print_heap_transition();
-    gclog_or_tty->print_cr(", %3.7f secs]", pause_time_sec);
-  }
-  gclog_or_tty->flush();
-}
+void G1CollectedHeap::log_gc_footer(double pause_time_counter) {
+  if (evacuation_failed()) {
+    log_info(gc)("To-space exhausted");
+  }
+
+  double pause_time_sec = TimeHelper::counter_to_seconds(pause_time_counter);
+  g1_policy()->print_phases(pause_time_sec);
+
+  g1_policy()->print_detailed_heap_transition();
+}
+
 
 void G1CollectedHeap::wait_for_root_region_scanning() {
   double scan_wait_start = os::elapsedTime();
@@ -3764,7 +3662,6 @@
 
   wait_for_root_region_scanning();
 
-  G1Log::update_level();
   print_heap_before_gc();
   trace_heap_before_gc(_gc_tracer_stw);
 
@@ -3801,16 +3698,25 @@
 
     _gc_tracer_stw->report_yc_type(collector_state()->yc_type());
 
-    TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
+    GCTraceCPUTime tcpu;
 
     uint active_workers = AdaptiveSizePolicy::calc_active_workers(workers()->total_workers(),
                                                                   workers()->active_workers(),
                                                                   Threads::number_of_non_daemon_threads());
     workers()->set_active_workers(active_workers);
+    FormatBuffer<> gc_string("Pause ");
+    if (collector_state()->during_initial_mark_pause()) {
+      gc_string.append("Initial Mark");
+    } else if (collector_state()->gcs_are_young()) {
+      gc_string.append("Young");
+    } else {
+      gc_string.append("Mixed");
+    }
+    GCTraceTime(Info, gc) tm(gc_string, NULL, gc_cause(), true);
 
     double pause_start_sec = os::elapsedTime();
+    double pause_start_counter = os::elapsed_counter();
     g1_policy()->note_gc_start(active_workers);
-    log_gc_header();
 
     TraceCollectorStats tcs(g1mm()->incremental_collection_counters());
     TraceMemoryManagerStats tms(false /* fullGC */, gc_cause());
@@ -3868,11 +3774,6 @@
         // of the collection set!).
         _allocator->release_mutator_alloc_region();
 
-        // We should call this after we retire the mutator alloc
-        // region(s) so that all the ALLOC / RETIRE events are generated
-        // before the start GC event.
-        _hr_printer.start_gc(false /* full */, (size_t) total_collections());
-
         // This timing is only used by the ergonomics to handle our pause target.
         // It is unclear why this should not include the full pause. We will
         // investigate this in CR 7178365.
@@ -3996,7 +3897,7 @@
           size_t expand_bytes = g1_policy()->expansion_amount();
           if (expand_bytes > 0) {
             size_t bytes_before = capacity();
-            // No need for an ergo verbose message here,
+            // No need for an ergo logging here,
             // expansion_amount() does this when it returns a value > 0.
             double expand_ms;
             if (!expand(expand_bytes, &expand_ms)) {
@@ -4056,12 +3957,6 @@
         // CM reference discovery will be re-enabled if necessary.
       }
 
-      // We should do this after we potentially expand the heap so
-      // that all the COMMIT events are generated before the end GC
-      // event, and after we retire the GC alloc regions so that all
-      // RETIRE events are generated before the end GC event.
-      _hr_printer.end_gc(false /* full */, (size_t) total_collections());
-
 #ifdef TRACESPINNING
       ParallelTaskTerminator::print_termination_counts();
 #endif
@@ -4070,7 +3965,7 @@
     }
 
     // Print the remainder of the GC log output.
-    log_gc_footer(os::elapsedTime() - pause_start_sec);
+    log_gc_footer(os::elapsed_counter() - pause_start_counter);
 
     // It is not yet to safe to tell the concurrent mark to
     // start as we have some optional output below. We don't want the
@@ -4080,7 +3975,7 @@
     _hrm.verify_optional();
     verify_region_sets_optional();
 
-    TASKQUEUE_STATS_ONLY(if (PrintTaskqueue) print_taskqueue_stats());
+    TASKQUEUE_STATS_ONLY(print_taskqueue_stats());
     TASKQUEUE_STATS_ONLY(reset_taskqueue_stats());
 
     print_heap_after_gc();
@@ -4235,13 +4130,12 @@
 
       assert(pss->queue_is_empty(), "should be empty");
 
-      if (PrintTerminationStats) {
+      if (log_is_enabled(Debug, gc, task, stats)) {
         MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
         size_t lab_waste;
         size_t lab_undo_waste;
         pss->waste(lab_waste, lab_undo_waste);
-        _g1h->print_termination_stats(gclog_or_tty,
-                                      worker_id,
+        _g1h->print_termination_stats(worker_id,
                                       (os::elapsedTime() - start_sec) * 1000.0,   /* elapsed time */
                                       strong_roots_sec * 1000.0,                  /* strong roots time */
                                       term_sec * 1000.0,                          /* evac term time */
@@ -4259,22 +4153,22 @@
   }
 };
 
-void G1CollectedHeap::print_termination_stats_hdr(outputStream* const st) {
-  st->print_raw_cr("GC Termination Stats");
-  st->print_raw_cr("     elapsed  --strong roots-- -------termination------- ------waste (KiB)------");
-  st->print_raw_cr("thr     ms        ms      %        ms      %    attempts  total   alloc    undo");
-  st->print_raw_cr("--- --------- --------- ------ --------- ------ -------- ------- ------- -------");
-}
-
-void G1CollectedHeap::print_termination_stats(outputStream* const st,
-                                              uint worker_id,
+void G1CollectedHeap::print_termination_stats_hdr() {
+  log_debug(gc, task, stats)("GC Termination Stats");
+  log_debug(gc, task, stats)("     elapsed  --strong roots-- -------termination------- ------waste (KiB)------");
+  log_debug(gc, task, stats)("thr     ms        ms      %%        ms      %%    attempts  total   alloc    undo");
+  log_debug(gc, task, stats)("--- --------- --------- ------ --------- ------ -------- ------- ------- -------");
+}
+
+void G1CollectedHeap::print_termination_stats(uint worker_id,
                                               double elapsed_ms,
                                               double strong_roots_ms,
                                               double term_ms,
                                               size_t term_attempts,
                                               size_t alloc_buffer_waste,
                                               size_t undo_waste) const {
-  st->print_cr("%3d %9.2f %9.2f %6.2f "
+  log_debug(gc, task, stats)
+              ("%3d %9.2f %9.2f %6.2f "
                "%9.2f %6.2f " SIZE_FORMAT_W(8) " "
                SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7) " " SIZE_FORMAT_W(7),
                worker_id, elapsed_ms, strong_roots_ms, strong_roots_ms * 100 / elapsed_ms,
@@ -4323,13 +4217,11 @@
               "claim value %d after unlink less than initial symbol table size %d",
               SymbolTable::parallel_claimed_index(), _initial_symbol_table_size);
 
-    if (G1TraceStringSymbolTableScrubbing) {
-      gclog_or_tty->print_cr("Cleaned string and symbol table, "
-                             "strings: " SIZE_FORMAT " processed, " SIZE_FORMAT " removed, "
-                             "symbols: " SIZE_FORMAT " processed, " SIZE_FORMAT " removed",
-                             strings_processed(), strings_removed(),
-                             symbols_processed(), symbols_removed());
-    }
+    log_debug(gc, stringdedup)("Cleaned string and symbol table, "
+                               "strings: " SIZE_FORMAT " processed, " SIZE_FORMAT " removed, "
+                               "symbols: " SIZE_FORMAT " processed, " SIZE_FORMAT " removed",
+                               strings_processed(), strings_removed(),
+                               symbols_processed(), symbols_removed());
   }
 
   void work(uint worker_id) {
@@ -5169,10 +5061,7 @@
       ClassLoaderDataGraph::clear_claimed_marks();
     }
 
-    // The individual threads will set their evac-failure closures.
-    if (PrintTerminationStats) {
-      print_termination_stats_hdr(gclog_or_tty);
-    }
+    print_termination_stats_hdr();
 
     workers()->run_task(&g1_par_task);
     end_par_time_sec = os::elapsedTime();
@@ -5411,11 +5300,8 @@
             "tams: " PTR_FORMAT " end: " PTR_FORMAT, p2i(tams), p2i(end));
   HeapWord* result = bitmap->getNextMarkedWordAddress(tams, end);
   if (result < end) {
-    gclog_or_tty->cr();
-    gclog_or_tty->print_cr("## wrong marked address on %s bitmap: " PTR_FORMAT,
-                           bitmap_name, p2i(result));
-    gclog_or_tty->print_cr("## %s tams: " PTR_FORMAT " end: " PTR_FORMAT,
-                           bitmap_name, p2i(tams), p2i(end));
+    log_info(gc, verify)("## wrong marked address on %s bitmap: " PTR_FORMAT, bitmap_name, p2i(result));
+    log_info(gc, verify)("## %s tams: " PTR_FORMAT " end: " PTR_FORMAT, bitmap_name, p2i(tams), p2i(end));
     return false;
   }
   return true;
@@ -5440,9 +5326,8 @@
     res_n = verify_no_bits_over_tams("next", next_bitmap, ntams, end);
   }
   if (!res_p || !res_n) {
-    gclog_or_tty->print_cr("#### Bitmap verification failed for " HR_FORMAT,
-                           HR_FORMAT_PARAMS(hr));
-    gclog_or_tty->print_cr("#### Caller: %s", caller);
+    log_info(gc, verify)("#### Bitmap verification failed for " HR_FORMAT, HR_FORMAT_PARAMS(hr));
+    log_info(gc, verify)("#### Caller: %s", caller);
     return false;
   }
   return true;
@@ -5494,42 +5379,42 @@
     InCSetState cset_state = (InCSetState) G1CollectedHeap::heap()->_in_cset_fast_test.get_by_index(i);
     if (hr->is_humongous()) {
       if (hr->in_collection_set()) {
-        gclog_or_tty->print_cr("\n## humongous region %u in CSet", i);
+        log_info(gc, verify)("## humongous region %u in CSet", i);
         _failures = true;
         return true;
       }
       if (cset_state.is_in_cset()) {
-        gclog_or_tty->print_cr("\n## inconsistent cset state " CSETSTATE_FORMAT " for humongous region %u", cset_state.value(), i);
+        log_info(gc, verify)("## inconsistent cset state " CSETSTATE_FORMAT " for humongous region %u", cset_state.value(), i);
         _failures = true;
         return true;
       }
       if (hr->is_continues_humongous() && cset_state.is_humongous()) {
-        gclog_or_tty->print_cr("\n## inconsistent cset state " CSETSTATE_FORMAT " for continues humongous region %u", cset_state.value(), i);
+        log_info(gc, verify)("## inconsistent cset state " CSETSTATE_FORMAT " for continues humongous region %u", cset_state.value(), i);
         _failures = true;
         return true;
       }
     } else {
       if (cset_state.is_humongous()) {
-        gclog_or_tty->print_cr("\n## inconsistent cset state " CSETSTATE_FORMAT " for non-humongous region %u", cset_state.value(), i);
+        log_info(gc, verify)("## inconsistent cset state " CSETSTATE_FORMAT " for non-humongous region %u", cset_state.value(), i);
         _failures = true;
         return true;
       }
       if (hr->in_collection_set() != cset_state.is_in_cset()) {
-        gclog_or_tty->print_cr("\n## in CSet %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
-                               hr->in_collection_set(), cset_state.value(), i);
+        log_info(gc, verify)("## in CSet %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
+                             hr->in_collection_set(), cset_state.value(), i);
         _failures = true;
         return true;
       }
       if (cset_state.is_in_cset()) {
         if (hr->is_young() != (cset_state.is_young())) {
-          gclog_or_tty->print_cr("\n## is_young %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
-                                 hr->is_young(), cset_state.value(), i);
+          log_info(gc, verify)("## is_young %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
+                               hr->is_young(), cset_state.value(), i);
           _failures = true;
           return true;
         }
         if (hr->is_old() != (cset_state.is_old())) {
-          gclog_or_tty->print_cr("\n## is_old %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
-                                 hr->is_old(), cset_state.value(), i);
+          log_info(gc, verify)("## is_old %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
+                               hr->is_old(), cset_state.value(), i);
           _failures = true;
           return true;
         }
@@ -5746,9 +5631,7 @@
     uint region_idx = r->hrm_index();
     if (!g1h->is_humongous_reclaim_candidate(region_idx) ||
         !r->rem_set()->is_empty()) {
-
-      if (G1TraceEagerReclaimHumongousObjects) {
-        gclog_or_tty->print_cr("Live humongous region %u object size " SIZE_FORMAT " start " PTR_FORMAT "  with remset " SIZE_FORMAT " code roots " SIZE_FORMAT " is marked %d reclaim candidate %d type array %d",
+      log_debug(gc, humongous)("Live humongous region %u object size " SIZE_FORMAT " start " PTR_FORMAT "  with remset " SIZE_FORMAT " code roots " SIZE_FORMAT " is marked %d reclaim candidate %d type array %d",
                                region_idx,
                                (size_t)obj->size() * HeapWordSize,
                                p2i(r->bottom()),
@@ -5758,8 +5641,6 @@
                                g1h->is_humongous_reclaim_candidate(region_idx),
                                obj->is_typeArray()
                               );
-      }
-
       return false;
     }
 
@@ -5767,8 +5648,7 @@
               "Only eagerly reclaiming type arrays is supported, but the object "
               PTR_FORMAT " is not.", p2i(r->bottom()));
 
-    if (G1TraceEagerReclaimHumongousObjects) {
-      gclog_or_tty->print_cr("Dead humongous region %u object size " SIZE_FORMAT " start " PTR_FORMAT " with remset " SIZE_FORMAT " code roots " SIZE_FORMAT " is marked %d reclaim candidate %d type array %d",
+    log_debug(gc, humongous)("Dead humongous region %u object size " SIZE_FORMAT " start " PTR_FORMAT " with remset " SIZE_FORMAT " code roots " SIZE_FORMAT " is marked %d reclaim candidate %d type array %d",
                              region_idx,
                              (size_t)obj->size() * HeapWordSize,
                              p2i(r->bottom()),
@@ -5778,7 +5658,7 @@
                              g1h->is_humongous_reclaim_candidate(region_idx),
                              obj->is_typeArray()
                             );
-    }
+
     // Need to clear mark bit of the humongous object if already set.
     if (next_bitmap->isMarked(r->bottom())) {
       next_bitmap->clear(r->bottom());
@@ -5812,7 +5692,7 @@
   assert_at_safepoint(true);
 
   if (!G1EagerReclaimHumongousObjects ||
-      (!_has_humongous_reclaim_candidates && !G1TraceEagerReclaimHumongousObjects)) {
+      (!_has_humongous_reclaim_candidates && !log_is_enabled(Debug, gc, humongous))) {
     g1_policy()->phase_times()->record_fast_reclaim_humongous_time_ms(0.0, 0);
     return;
   }
@@ -5865,10 +5745,7 @@
 }
 
 void G1CollectedHeap::set_free_regions_coming() {
-  if (G1ConcRegionFreeingVerbose) {
-    gclog_or_tty->print_cr("G1ConcRegionFreeing [cm thread] : "
-                           "setting free regions coming");
-  }
+  log_develop_trace(gc, freelist)("G1ConcRegionFreeing [cm thread] : setting free regions coming");
 
   assert(!free_regions_coming(), "pre-condition");
   _free_regions_coming = true;
@@ -5883,10 +5760,7 @@
     SecondaryFreeList_lock->notify_all();
   }
 
-  if (G1ConcRegionFreeingVerbose) {
-    gclog_or_tty->print_cr("G1ConcRegionFreeing [cm thread] : "
-                           "reset free regions coming");
-  }
+  log_develop_trace(gc, freelist)("G1ConcRegionFreeing [cm thread] : reset free regions coming");
 }
 
 void G1CollectedHeap::wait_while_free_regions_coming() {
@@ -5896,10 +5770,7 @@
     return;
   }
 
-  if (G1ConcRegionFreeingVerbose) {
-    gclog_or_tty->print_cr("G1ConcRegionFreeing [other] : "
-                           "waiting for free regions");
-  }
+  log_develop_trace(gc, freelist)("G1ConcRegionFreeing [other] : waiting for free regions");
 
   {
     MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);
@@ -5908,10 +5779,7 @@
     }
   }
 
-  if (G1ConcRegionFreeingVerbose) {
-    gclog_or_tty->print_cr("G1ConcRegionFreeing [other] : "
-                           "done waiting for free regions");
-  }
+  log_develop_trace(gc, freelist)("G1ConcRegionFreeing [other] : done waiting for free regions");
 }
 
 bool G1CollectedHeap::is_old_gc_alloc_region(HeapRegion* hr) {
@@ -5929,8 +5797,8 @@
   NoYoungRegionsClosure() : _success(true) { }
   bool doHeapRegion(HeapRegion* r) {
     if (r->is_young()) {
-      gclog_or_tty->print_cr("Region [" PTR_FORMAT ", " PTR_FORMAT ") tagged as young",
-                             p2i(r->bottom()), p2i(r->end()));
+      log_info(gc, verify)("Region [" PTR_FORMAT ", " PTR_FORMAT ") tagged as young",
+                           p2i(r->bottom()), p2i(r->end()));
       _success = false;
     }
     return false;
@@ -6180,11 +6048,8 @@
 
   if (index != G1_NO_HRM_INDEX) {
     if (expanded) {
-      ergo_verbose1(ErgoHeapSizing,
-                    "attempt heap expansion",
-                    ergo_format_reason("requested address range outside heap bounds")
-                    ergo_format_byte("region size"),
-                    HeapRegion::GrainWords * HeapWordSize);
+      log_debug(gc, ergo, heap)("Attempt heap expansion (requested address range outside heap bounds). region size: " SIZE_FORMAT "B",
+                                HeapRegion::GrainWords * HeapWordSize);
     }
     _hrm.allocate_free_regions_starting_at(index, 1);
     return region_at(index);
--- a/src/share/vm/gc/g1/g1CollectedHeap.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1CollectedHeap.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -290,8 +290,7 @@
   void verify_before_gc();
   void verify_after_gc();
 
-  void log_gc_header();
-  void log_gc_footer(double pause_time_sec);
+  void log_gc_footer(double pause_time_counter);
 
   void trace_heap(GCWhen::Type when, const GCTracer* tracer);
 
@@ -704,8 +703,8 @@
   void shrink_helper(size_t expand_bytes);
 
   #if TASKQUEUE_STATS
-  static void print_taskqueue_stats_hdr(outputStream* const st = gclog_or_tty);
-  void print_taskqueue_stats(outputStream* const st = gclog_or_tty) const;
+  static void print_taskqueue_stats_hdr(outputStream* const st);
+  void print_taskqueue_stats() const;
   void reset_taskqueue_stats();
   #endif // TASKQUEUE_STATS
 
@@ -738,10 +737,9 @@
   void post_evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* pss);
 
   // Print the header for the per-thread termination statistics.
-  static void print_termination_stats_hdr(outputStream* const st);
+  static void print_termination_stats_hdr();
   // Print actual per-thread termination statistics.
-  void print_termination_stats(outputStream* const st,
-                               uint worker_id,
+  void print_termination_stats(uint worker_id,
                                double elapsed_ms,
                                double strong_roots_ms,
                                double term_ms,
@@ -968,6 +966,10 @@
     return CollectedHeap::G1CollectedHeap;
   }
 
+  virtual const char* name() const {
+    return "G1";
+  }
+
   const G1CollectorState* collector_state() const { return &_collector_state; }
   G1CollectorState* collector_state() { return &_collector_state; }
 
@@ -1365,6 +1367,10 @@
 
   YoungList* young_list() const { return _young_list; }
 
+  uint old_regions_count() const { return _old_set.length(); }
+
+  uint humongous_regions_count() const { return _humongous_set.length(); }
+
   // debugging
   bool check_young_list_well_formed() {
     return _young_list->check_list_well_formed();
@@ -1482,10 +1488,7 @@
   // Currently there is only one place where this is called with
   // vo == UseMarkWord, which is to verify the marking during a
   // full GC.
-  void verify(bool silent, VerifyOption vo);
-
-  // Override; it uses the "prev" marking information
-  virtual void verify(bool silent);
+  void verify(VerifyOption vo);
 
   // The methods below are here for convenience and dispatch the
   // appropriate method depending on value of the given VerifyOption
--- a/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -29,9 +29,7 @@
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1IHOPControl.hpp"
-#include "gc/g1/g1ErgoVerbose.hpp"
 #include "gc/g1/g1GCPhaseTimes.hpp"
-#include "gc/g1/g1Log.hpp"
 #include "gc/g1/heapRegion.inline.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
 #include "gc/shared/gcPolicyCounters.hpp"
@@ -121,6 +119,8 @@
 
   _eden_used_bytes_before_gc(0),
   _survivor_used_bytes_before_gc(0),
+  _old_used_bytes_before_gc(0),
+  _humongous_used_bytes_before_gc(0),
   _heap_used_bytes_before_gc(0),
   _metaspace_used_bytes_before_gc(0),
   _eden_capacity_bytes_before_gc(0),
@@ -177,18 +177,6 @@
   HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize);
   HeapRegionRemSet::setup_remset_size();
 
-  G1ErgoVerbose::initialize();
-  if (PrintAdaptiveSizePolicy) {
-    // Currently, we only use a single switch for all the heuristics.
-    G1ErgoVerbose::set_enabled(true);
-    // Given that we don't currently have a verboseness level
-    // parameter, we'll hardcode this to high. This can be easily
-    // changed in the future.
-    G1ErgoVerbose::set_level(ErgoHigh);
-  } else {
-    G1ErgoVerbose::set_enabled(false);
-  }
-
   _recent_prev_end_times_for_all_gcs_sec->add(os::elapsedTime());
   _prev_collection_pause_end_ms = os::elapsedTime() * 1000.0;
   clear_ratio_check_data();
@@ -791,7 +779,7 @@
        curr = curr->get_next_young_region()) {
     SurvRateGroup* group = curr->surv_rate_group();
     if (group == NULL && !curr->is_survivor()) {
-      gclog_or_tty->print_cr("## %s: encountered NULL surv_rate_group", name);
+      log_info(gc, verify)("## %s: encountered NULL surv_rate_group", name);
       ret = false;
     }
 
@@ -799,13 +787,12 @@
       int age = curr->age_in_surv_rate_group();
 
       if (age < 0) {
-        gclog_or_tty->print_cr("## %s: encountered negative age", name);
+        log_info(gc, verify)("## %s: encountered negative age", name);
         ret = false;
       }
 
       if (age <= prev_age) {
-        gclog_or_tty->print_cr("## %s: region ages are not strictly increasing "
-                               "(%d, %d)", name, age, prev_age);
+        log_info(gc, verify)("## %s: region ages are not strictly increasing (%d, %d)", name, age, prev_age);
         ret = false;
       }
       prev_age = age;
@@ -982,38 +969,15 @@
   size_t alloc_byte_size = alloc_word_size * HeapWordSize;
   size_t marking_request_bytes = cur_used_bytes + alloc_byte_size;
 
+  bool result = false;
   if (marking_request_bytes > marking_initiating_used_threshold) {
-    if (collector_state()->gcs_are_young() && !collector_state()->last_young_gc()) {
-      ergo_verbose5(ErgoConcCycles,
-        "request concurrent cycle initiation",
-        ergo_format_reason("occupancy higher than threshold")
-        ergo_format_byte("occupancy")
-        ergo_format_byte("allocation request")
-        ergo_format_byte_perc("threshold")
-        ergo_format_str("source"),
-        cur_used_bytes,
-        alloc_byte_size,
-        marking_initiating_used_threshold,
-        (double) marking_initiating_used_threshold / _g1->capacity() * 100,
-        source);
-      return true;
-    } else {
-      ergo_verbose5(ErgoConcCycles,
-        "do not request concurrent cycle initiation",
-        ergo_format_reason("still doing mixed collections")
-        ergo_format_byte("occupancy")
-        ergo_format_byte("allocation request")
-        ergo_format_byte_perc("threshold")
-        ergo_format_str("source"),
-        cur_used_bytes,
-        alloc_byte_size,
-        marking_initiating_used_threshold,
-        (double) InitiatingHeapOccupancyPercent,
-        source);
-    }
+    result = collector_state()->gcs_are_young() && !collector_state()->last_young_gc();
+    log_debug(gc, ergo, ihop)("%s occupancy: " SIZE_FORMAT "B allocation request: " SIZE_FORMAT "B threshold: " SIZE_FORMAT "B (%1.2f) source: %s",
+                              result ? "Request concurrent cycle initiation (occupancy higher than threshold)" : "Do not request concurrent cycle initiation (still doing mixed collections)",
+                              cur_used_bytes, alloc_byte_size, marking_initiating_used_threshold, (double) marking_initiating_used_threshold / _g1->capacity() * 100, source);
   }
 
-  return false;
+  return result;
 }
 
 // Anything below that is considered to be zero
@@ -1027,13 +991,7 @@
   bool last_pause_included_initial_mark = false;
   bool update_stats = !_g1->evacuation_failed();
 
-#ifndef PRODUCT
-  if (G1YoungSurvRateVerbose) {
-    gclog_or_tty->cr();
-    _short_lived_surv_rate_group->print();
-    // do that for any other surv rate groups too
-  }
-#endif // PRODUCT
+  NOT_PRODUCT(_short_lived_surv_rate_group->print());
 
   record_pause(young_gc_pause_kind(), end_time_sec - pause_time_ms / 1000.0, end_time_sec);
 
@@ -1228,13 +1186,9 @@
   double scan_hcc_time_ms = average_time_ms(G1GCPhaseTimes::ScanHCC);
 
   if (update_rs_time_goal_ms < scan_hcc_time_ms) {
-    ergo_verbose2(ErgoTiming,
-                  "adjust concurrent refinement thresholds",
-                  ergo_format_reason("Scanning the HCC expected to take longer than Update RS time goal")
-                  ergo_format_ms("Update RS time goal")
-                  ergo_format_ms("Scan HCC time"),
-                  update_rs_time_goal_ms,
-                  scan_hcc_time_ms);
+    log_debug(gc, ergo, refine)("Adjust concurrent refinement thresholds (scanning the HCC expected to take longer than Update RS time goal)."
+                                "Update RS time goal: %1.2fms Scan HCC time: %1.2fms",
+                                update_rs_time_goal_ms, scan_hcc_time_ms);
 
     update_rs_time_goal_ms = 0;
   } else {
@@ -1312,65 +1266,37 @@
   _eden_used_bytes_before_gc = young_list->eden_used_bytes();
   _survivor_used_bytes_before_gc = young_list->survivor_used_bytes();
   _heap_capacity_bytes_before_gc = _g1->capacity();
+  _old_used_bytes_before_gc = _g1->old_regions_count() * HeapRegion::GrainBytes;
+  _humongous_used_bytes_before_gc = _g1->humongous_regions_count() * HeapRegion::GrainBytes;
   _heap_used_bytes_before_gc = _g1->used();
-
-  _eden_capacity_bytes_before_gc =
-         (_young_list_target_length * HeapRegion::GrainBytes) - _survivor_used_bytes_before_gc;
-
-  if (full) {
-    _metaspace_used_bytes_before_gc = MetaspaceAux::used_bytes();
-  }
+  _eden_capacity_bytes_before_gc = (_young_list_target_length * HeapRegion::GrainBytes) - _survivor_used_bytes_before_gc;
+  _metaspace_used_bytes_before_gc = MetaspaceAux::used_bytes();
 }
 
-void G1CollectorPolicy::print_heap_transition(size_t bytes_before) const {
-  size_t bytes_after = _g1->used();
-  size_t capacity = _g1->capacity();
-
-  gclog_or_tty->print(" " SIZE_FORMAT "%s->" SIZE_FORMAT "%s(" SIZE_FORMAT "%s)",
-      byte_size_in_proper_unit(bytes_before),
-      proper_unit_for_byte_size(bytes_before),
-      byte_size_in_proper_unit(bytes_after),
-      proper_unit_for_byte_size(bytes_after),
-      byte_size_in_proper_unit(capacity),
-      proper_unit_for_byte_size(capacity));
-}
-
-void G1CollectorPolicy::print_heap_transition() const {
-  print_heap_transition(_heap_used_bytes_before_gc);
-}
-
-void G1CollectorPolicy::print_detailed_heap_transition(bool full) const {
+void G1CollectorPolicy::print_detailed_heap_transition() const {
   YoungList* young_list = _g1->young_list();
 
   size_t eden_used_bytes_after_gc = young_list->eden_used_bytes();
   size_t survivor_used_bytes_after_gc = young_list->survivor_used_bytes();
   size_t heap_used_bytes_after_gc = _g1->used();
+  size_t old_used_bytes_after_gc = _g1->old_regions_count() * HeapRegion::GrainBytes;
+  size_t humongous_used_bytes_after_gc = _g1->humongous_regions_count() * HeapRegion::GrainBytes;
 
   size_t heap_capacity_bytes_after_gc = _g1->capacity();
   size_t eden_capacity_bytes_after_gc =
     (_young_list_target_length * HeapRegion::GrainBytes) - survivor_used_bytes_after_gc;
+  size_t survivor_capacity_bytes_after_gc = _max_survivor_regions * HeapRegion::GrainBytes;
 
-  gclog_or_tty->print(
-    "   [Eden: " EXT_SIZE_FORMAT "(" EXT_SIZE_FORMAT ")->" EXT_SIZE_FORMAT "(" EXT_SIZE_FORMAT ") "
-    "Survivors: " EXT_SIZE_FORMAT "->" EXT_SIZE_FORMAT " "
-    "Heap: " EXT_SIZE_FORMAT "(" EXT_SIZE_FORMAT ")->"
-    EXT_SIZE_FORMAT "(" EXT_SIZE_FORMAT ")]",
-    EXT_SIZE_PARAMS(_eden_used_bytes_before_gc),
-    EXT_SIZE_PARAMS(_eden_capacity_bytes_before_gc),
-    EXT_SIZE_PARAMS(eden_used_bytes_after_gc),
-    EXT_SIZE_PARAMS(eden_capacity_bytes_after_gc),
-    EXT_SIZE_PARAMS(_survivor_used_bytes_before_gc),
-    EXT_SIZE_PARAMS(survivor_used_bytes_after_gc),
-    EXT_SIZE_PARAMS(_heap_used_bytes_before_gc),
-    EXT_SIZE_PARAMS(_heap_capacity_bytes_before_gc),
-    EXT_SIZE_PARAMS(heap_used_bytes_after_gc),
-    EXT_SIZE_PARAMS(heap_capacity_bytes_after_gc));
+  log_info(gc, heap)("Eden: " SIZE_FORMAT "K->" SIZE_FORMAT "K("  SIZE_FORMAT "K)",
+                     _eden_used_bytes_before_gc / K, eden_used_bytes_after_gc /K, eden_capacity_bytes_after_gc /K);
+  log_info(gc, heap)("Survivor: " SIZE_FORMAT "K->" SIZE_FORMAT "K("  SIZE_FORMAT "K)",
+                     _survivor_used_bytes_before_gc / K, survivor_used_bytes_after_gc /K, survivor_capacity_bytes_after_gc /K);
+  log_info(gc, heap)("Old: " SIZE_FORMAT "K->" SIZE_FORMAT "K",
+                     _old_used_bytes_before_gc / K, old_used_bytes_after_gc /K);
+  log_info(gc, heap)("Humongous: " SIZE_FORMAT "K->" SIZE_FORMAT "K",
+                     _humongous_used_bytes_before_gc / K, humongous_used_bytes_after_gc /K);
 
-  if (full) {
-    MetaspaceAux::print_metaspace_change(_metaspace_used_bytes_before_gc);
-  }
-
-  gclog_or_tty->cr();
+  MetaspaceAux::print_metaspace_change(_metaspace_used_bytes_before_gc);
 }
 
 void G1CollectorPolicy::print_phases(double pause_time_sec) {
@@ -1690,17 +1616,9 @@
       }
     }
 
-    ergo_verbose5(ErgoHeapSizing,
-                  "attempt heap expansion",
-                  ergo_format_reason("recent GC overhead higher than "
-                                     "threshold after GC")
-                  ergo_format_perc("recent GC overhead")
-                  ergo_format_perc("current threshold")
-                  ergo_format_byte("uncommitted")
-                  ergo_format_byte_perc("base expansion amount and scale"),
-                  recent_gc_overhead, threshold,
-                  uncommitted_bytes,
-                  expand_bytes, scale_factor * 100);
+    log_debug(gc, ergo, heap)("Attempt heap expansion (recent GC overhead higher than threshold after GC) "
+                              "recent GC overhead: %1.2f %% threshold: %1.2f %% uncommitted: " SIZE_FORMAT "B base expansion amount and scale: " SIZE_FORMAT "B (%1.2f%%)",
+                              recent_gc_overhead, threshold, uncommitted_bytes, expand_bytes, scale_factor * 100);
 
     expand_bytes = static_cast<size_t>(expand_bytes * scale_factor);
 
@@ -1783,19 +1701,11 @@
   // even while we are still in the process of reclaiming memory.
   bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle();
   if (!during_cycle) {
-    ergo_verbose1(ErgoConcCycles,
-                  "request concurrent cycle initiation",
-                  ergo_format_reason("requested by GC cause")
-                  ergo_format_str("GC cause"),
-                  GCCause::to_string(gc_cause));
+    log_debug(gc, ergo)("Request concurrent cycle initiation (requested by GC cause). GC cause: %s", GCCause::to_string(gc_cause));
     collector_state()->set_initiate_conc_mark_if_possible(true);
     return true;
   } else {
-    ergo_verbose1(ErgoConcCycles,
-                  "do not request concurrent cycle initiation",
-                  ergo_format_reason("concurrent cycle already in progress")
-                  ergo_format_str("GC cause"),
-                  GCCause::to_string(gc_cause));
+    log_debug(gc, ergo)("Do not request concurrent cycle initiation (concurrent cycle already in progress). GC cause: %s", GCCause::to_string(gc_cause));
     return false;
   }
 }
@@ -1823,9 +1733,7 @@
     if (!about_to_start_mixed_phase() && collector_state()->gcs_are_young()) {
       // Initiate a new initial mark if there is no marking or reclamation going on.
       initiate_conc_mark();
-      ergo_verbose0(ErgoConcCycles,
-                    "initiate concurrent cycle",
-                    ergo_format_reason("concurrent cycle initiation requested"));
+      log_debug(gc, ergo)("Initiate concurrent cycle (concurrent cycle initiation requested)");
     } else if (_g1->is_user_requested_concurrent_full_gc(_g1->gc_cause())) {
       // Initiate a user requested initial mark. An initial mark must be young only
       // GC, so the collector state must be updated to reflect this.
@@ -1834,9 +1742,7 @@
 
       abort_time_to_mixed_tracking();
       initiate_conc_mark();
-      ergo_verbose0(ErgoConcCycles,
-                    "initiate concurrent cycle",
-                    ergo_format_reason("user requested concurrent cycle"));
+      log_debug(gc, ergo)("Initiate concurrent cycle (user requested concurrent cycle)");
     } else {
       // The concurrent marking thread is still finishing up the
       // previous cycle. If we start one right now the two cycles
@@ -1850,9 +1756,7 @@
       // and, if it's in a yield point, it's waiting for us to
       // finish. So, at this point we will not start a cycle and we'll
       // let the concurrent marking thread complete the last one.
-      ergo_verbose0(ErgoConcCycles,
-                    "do not initiate concurrent cycle",
-                    ergo_format_reason("concurrent cycle already in progress"));
+      log_debug(gc, ergo)("Do not initiate concurrent cycle (concurrent cycle already in progress)");
     }
   }
 }
@@ -2197,9 +2101,7 @@
 bool G1CollectorPolicy::next_gc_should_be_mixed(const char* true_action_str,
                                                 const char* false_action_str) const {
   if (cset_chooser()->is_empty()) {
-    ergo_verbose0(ErgoMixedGCs,
-                  false_action_str,
-                  ergo_format_reason("candidate old regions not available"));
+    log_debug(gc, ergo)("%s (candidate old regions not available)", false_action_str);
     return false;
   }
 
@@ -2208,27 +2110,12 @@
   double reclaimable_perc = reclaimable_bytes_perc(reclaimable_bytes);
   double threshold = (double) G1HeapWastePercent;
   if (reclaimable_perc <= threshold) {
-    ergo_verbose4(ErgoMixedGCs,
-              false_action_str,
-              ergo_format_reason("reclaimable percentage not over threshold")
-              ergo_format_region("candidate old regions")
-              ergo_format_byte_perc("reclaimable")
-              ergo_format_perc("threshold"),
-              cset_chooser()->remaining_regions(),
-              reclaimable_bytes,
-              reclaimable_perc, threshold);
+    log_debug(gc, ergo)("%s (reclaimable percentage not over threshold). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT,
+                        false_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_perc, G1HeapWastePercent);
     return false;
   }
-
-  ergo_verbose4(ErgoMixedGCs,
-                true_action_str,
-                ergo_format_reason("candidate old regions available")
-                ergo_format_region("candidate old regions")
-                ergo_format_byte_perc("reclaimable")
-                ergo_format_perc("threshold"),
-                cset_chooser()->remaining_regions(),
-                reclaimable_bytes,
-                reclaimable_perc, threshold);
+  log_debug(gc, ergo)("%s (candidate old regions available). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT,
+                      true_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_perc, G1HeapWastePercent);
   return true;
 }
 
@@ -2284,13 +2171,8 @@
   double base_time_ms = predict_base_elapsed_time_ms(_pending_cards);
   double time_remaining_ms = MAX2(target_pause_time_ms - base_time_ms, 0.0);
 
-  ergo_verbose4(ErgoCSetConstruction | ErgoHigh,
-                "start choosing CSet",
-                ergo_format_size("_pending_cards")
-                ergo_format_ms("predicted base time")
-                ergo_format_ms("remaining time")
-                ergo_format_ms("target pause time"),
-                _pending_cards, base_time_ms, time_remaining_ms, target_pause_time_ms);
+  log_trace(gc, ergo, cset)("Start choosing CSet. pending cards: " SIZE_FORMAT " predicted base time: %1.2fms remaining time: %1.2fms target pause time: %1.2fms",
+                            _pending_cards, base_time_ms, time_remaining_ms, target_pause_time_ms);
 
   collector_state()->set_last_gc_was_young(collector_state()->gcs_are_young());
 
@@ -2326,15 +2208,8 @@
   _collection_set_bytes_used_before = _inc_cset_bytes_used_before;
   time_remaining_ms = MAX2(time_remaining_ms - _inc_cset_predicted_elapsed_time_ms, 0.0);
 
-  ergo_verbose4(ErgoCSetConstruction | ErgoHigh,
-                "add young regions to CSet",
-                ergo_format_region("eden")
-                ergo_format_region("survivors")
-                ergo_format_ms("predicted young region time")
-                ergo_format_ms("target pause time"),
-                eden_region_length, survivor_region_length,
-                _inc_cset_predicted_elapsed_time_ms,
-                target_pause_time_ms);
+  log_trace(gc, ergo, cset)("Add young regions to CSet. eden: %u regions, survivors: %u regions, predicted young region time: %1.2fms, target pause time: %1.2fms",
+                            eden_region_length, survivor_region_length, _inc_cset_predicted_elapsed_time_ms, target_pause_time_ms);
 
   // The number of recorded young regions is the incremental
   // collection set's current size
@@ -2363,12 +2238,8 @@
     while (hr != NULL) {
       if (old_cset_region_length() >= max_old_cset_length) {
         // Added maximum number of old regions to the CSet.
-        ergo_verbose2(ErgoCSetConstruction,
-                      "finish adding old regions to CSet",
-                      ergo_format_reason("old CSet region num reached max")
-                      ergo_format_region("old")
-                      ergo_format_region("max"),
-                      old_cset_region_length(), max_old_cset_length);
+        log_debug(gc, ergo, cset)("Finish adding old regions to CSet (old CSet region num reached max). old %u regions, max %u regions",
+                                  old_cset_region_length(), max_old_cset_length);
         break;
       }
 
@@ -2382,17 +2253,9 @@
         // We've added enough old regions that the amount of uncollected
         // reclaimable space is at or below the waste threshold. Stop
         // adding old regions to the CSet.
-        ergo_verbose5(ErgoCSetConstruction,
-                      "finish adding old regions to CSet",
-                      ergo_format_reason("reclaimable percentage not over threshold")
-                      ergo_format_region("old")
-                      ergo_format_region("max")
-                      ergo_format_byte_perc("reclaimable")
-                      ergo_format_perc("threshold"),
-                      old_cset_region_length(),
-                      max_old_cset_length,
-                      reclaimable_bytes,
-                      reclaimable_perc, threshold);
+        log_debug(gc, ergo, cset)("Finish adding old regions to CSet (reclaimable percentage not over threshold). "
+                                  "old %u regions, max %u regions, reclaimable: " SIZE_FORMAT "B (%1.2f%%) threshold: " UINTX_FORMAT "%%",
+                                  old_cset_region_length(), max_old_cset_length, reclaimable_bytes, reclaimable_perc, G1HeapWastePercent);
         break;
       }
 
@@ -2404,15 +2267,9 @@
           if (old_cset_region_length() >= min_old_cset_length) {
             // We have added the minimum number of old regions to the CSet,
             // we are done with this CSet.
-            ergo_verbose4(ErgoCSetConstruction,
-                          "finish adding old regions to CSet",
-                          ergo_format_reason("predicted time is too high")
-                          ergo_format_ms("predicted time")
-                          ergo_format_ms("remaining time")
-                          ergo_format_region("old")
-                          ergo_format_region("min"),
-                          predicted_time_ms, time_remaining_ms,
-                          old_cset_region_length(), min_old_cset_length);
+            log_debug(gc, ergo, cset)("Finish adding old regions to CSet (predicted time is too high). "
+                                      "predicted time: %1.2fms, remaining time: %1.2fms old %u regions, min %u regions",
+                                      predicted_time_ms, time_remaining_ms, old_cset_region_length(), min_old_cset_length);
             break;
           }
 
@@ -2424,12 +2281,9 @@
         if (old_cset_region_length() >= min_old_cset_length) {
           // In the non-auto-tuning case, we'll finish adding regions
           // to the CSet if we reach the minimum.
-          ergo_verbose2(ErgoCSetConstruction,
-                        "finish adding old regions to CSet",
-                        ergo_format_reason("old CSet region num reached min")
-                        ergo_format_region("old")
-                        ergo_format_region("min"),
-                        old_cset_region_length(), min_old_cset_length);
+
+          log_debug(gc, ergo, cset)("Finish adding old regions to CSet (old CSet region num reached min). old %u regions, min %u regions",
+                                    old_cset_region_length(), min_old_cset_length);
           break;
         }
       }
@@ -2444,26 +2298,16 @@
       hr = cset_chooser()->peek();
     }
     if (hr == NULL) {
-      ergo_verbose0(ErgoCSetConstruction,
-                    "finish adding old regions to CSet",
-                    ergo_format_reason("candidate old regions not available"));
+      log_debug(gc, ergo, cset)("Finish adding old regions to CSet (candidate old regions not available)");
     }
 
     if (expensive_region_num > 0) {
       // We print the information once here at the end, predicated on
       // whether we added any apparently expensive regions or not, to
       // avoid generating output per region.
-      ergo_verbose4(ErgoCSetConstruction,
-                    "added expensive regions to CSet",
-                    ergo_format_reason("old CSet region num not reached min")
-                    ergo_format_region("old")
-                    ergo_format_region("expensive")
-                    ergo_format_region("min")
-                    ergo_format_ms("remaining time"),
-                    old_cset_region_length(),
-                    expensive_region_num,
-                    min_old_cset_length,
-                    time_remaining_ms);
+      log_debug(gc, ergo, cset)("Added expensive regions to CSet (old CSet region num not reached min)."
+                                "old %u regions, expensive: %u regions, min %u regions, remaining time: %1.2fms",
+                                old_cset_region_length(), expensive_region_num, min_old_cset_length, time_remaining_ms);
     }
 
     cset_chooser()->verify();
@@ -2471,13 +2315,8 @@
 
   stop_incremental_cset_building();
 
-  ergo_verbose3(ErgoCSetConstruction,
-                "finish choosing CSet",
-                ergo_format_region("old")
-                ergo_format_ms("predicted old region time")
-                ergo_format_ms("time remaining"),
-                old_cset_region_length(),
-                predicted_old_time_ms, time_remaining_ms);
+  log_debug(gc, ergo, cset)("Finish choosing CSet. old %u regions, predicted old region time: %1.2fms, time remaining: %1.2f",
+                            old_cset_region_length(), predicted_old_time_ms, time_remaining_ms);
 
   double non_young_end_time_sec = os::elapsedTime();
   phase_times()->record_non_young_cset_choice_time_ms((non_young_end_time_sec - non_young_start_time_sec) * 1000.0);
@@ -2536,14 +2375,14 @@
 void TraceYoungGenTimeData::print_summary(const char* str,
                                           const NumberSeq* seq) const {
   double sum = seq->sum();
-  gclog_or_tty->print_cr("%-27s = %8.2lf s (avg = %8.2lf ms)",
+  tty->print_cr("%-27s = %8.2lf s (avg = %8.2lf ms)",
                 str, sum / 1000.0, seq->avg());
 }
 
 void TraceYoungGenTimeData::print_summary_sd(const char* str,
                                              const NumberSeq* seq) const {
   print_summary(str, seq);
-  gclog_or_tty->print_cr("%45s = %5d, std dev = %8.2lf ms, max = %8.2lf ms)",
+  tty->print_cr("%45s = %5d, std dev = %8.2lf ms, max = %8.2lf ms)",
                 "(num", seq->num(), seq->sd(), seq->maximum());
 }
 
@@ -2552,18 +2391,18 @@
     return;
   }
 
-  gclog_or_tty->print_cr("ALL PAUSES");
+  tty->print_cr("ALL PAUSES");
   print_summary_sd("   Total", &_total);
-  gclog_or_tty->cr();
-  gclog_or_tty->cr();
-  gclog_or_tty->print_cr("   Young GC Pauses: %8d", _young_pause_num);
-  gclog_or_tty->print_cr("   Mixed GC Pauses: %8d", _mixed_pause_num);
-  gclog_or_tty->cr();
+  tty->cr();
+  tty->cr();
+  tty->print_cr("   Young GC Pauses: %8d", _young_pause_num);
+  tty->print_cr("   Mixed GC Pauses: %8d", _mixed_pause_num);
+  tty->cr();
 
-  gclog_or_tty->print_cr("EVACUATION PAUSES");
+  tty->print_cr("EVACUATION PAUSES");
 
   if (_young_pause_num == 0 && _mixed_pause_num == 0) {
-    gclog_or_tty->print_cr("none");
+    tty->print_cr("none");
   } else {
     print_summary_sd("   Evacuation Pauses", &_total);
     print_summary("      Root Region Scan Wait", &_root_region_scan_wait);
@@ -2578,9 +2417,9 @@
     print_summary("      Clear CT", &_clear_ct);
     print_summary("      Other", &_other);
   }
-  gclog_or_tty->cr();
+  tty->cr();
 
-  gclog_or_tty->print_cr("MISC");
+  tty->print_cr("MISC");
   print_summary_sd("   Stop World", &_all_stop_world_times_ms);
   print_summary_sd("   Yields", &_all_yield_times_ms);
 }
@@ -2597,11 +2436,11 @@
   }
 
   if (_all_full_gc_times.num() > 0) {
-    gclog_or_tty->print("\n%4d full_gcs: total time = %8.2f s",
+    tty->print("\n%4d full_gcs: total time = %8.2f s",
       _all_full_gc_times.num(),
       _all_full_gc_times.sum() / 1000.0);
-    gclog_or_tty->print_cr(" (avg = %8.2fms).", _all_full_gc_times.avg());
-    gclog_or_tty->print_cr("                     [std. dev = %8.2f ms, max = %8.2f ms]",
+    tty->print_cr(" (avg = %8.2fms).", _all_full_gc_times.avg());
+    tty->print_cr("                     [std. dev = %8.2f ms, max = %8.2f ms]",
       _all_full_gc_times.sd(),
       _all_full_gc_times.maximum());
   }
--- a/src/share/vm/gc/g1/g1CollectorPolicy.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1CollectorPolicy.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -159,6 +159,7 @@
   uint max_desired_young_length() {
     return _max_desired_young_length;
   }
+
   bool adaptive_young_list_length() const {
     return _adaptive_size;
   }
@@ -658,9 +659,7 @@
 
   // Print heap sizing transition (with less and more detail).
 
-  void print_heap_transition(size_t bytes_before) const;
-  void print_heap_transition() const;
-  void print_detailed_heap_transition(bool full = false) const;
+  void print_detailed_heap_transition() const;
 
   virtual void print_phases(double pause_time_sec);
 
@@ -827,6 +826,8 @@
 
   size_t _eden_used_bytes_before_gc;         // Eden occupancy before GC
   size_t _survivor_used_bytes_before_gc;     // Survivor occupancy before GC
+  size_t _old_used_bytes_before_gc;          // Old occupancy before GC
+  size_t _humongous_used_bytes_before_gc;    // Humongous occupancy before GC
   size_t _heap_used_bytes_before_gc;         // Heap occupancy before GC
   size_t _metaspace_used_bytes_before_gc;    // Metaspace occupancy before GC
 
--- a/src/share/vm/gc/g1/g1ErgoVerbose.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "gc/g1/g1ErgoVerbose.hpp"
-#include "utilities/ostream.hpp"
-
-ErgoLevel G1ErgoVerbose::_level;
-bool G1ErgoVerbose::_enabled[ErgoHeuristicNum];
-
-void G1ErgoVerbose::initialize() {
-  set_level(ErgoLow);
-  set_enabled(false);
-}
-
-void G1ErgoVerbose::set_level(ErgoLevel level) {
-  _level = level;
-}
-
-void G1ErgoVerbose::set_enabled(ErgoHeuristic n, bool enabled) {
-  assert(0 <= n && n < ErgoHeuristicNum, "pre-condition");
-  _enabled[n] = enabled;
-}
-
-void G1ErgoVerbose::set_enabled(bool enabled) {
-  for (int n = 0; n < ErgoHeuristicNum; n += 1) {
-    set_enabled((ErgoHeuristic) n, enabled);
-  }
-}
-
-const char* G1ErgoVerbose::to_string(int tag) {
-  ErgoHeuristic n = extract_heuristic(tag);
-  switch (n) {
-  case ErgoHeapSizing:        return "Heap Sizing";
-  case ErgoCSetConstruction:  return "CSet Construction";
-  case ErgoConcCycles:        return "Concurrent Cycles";
-  case ErgoMixedGCs:          return "Mixed GCs";
-  case ErgoTiming:            return "Timing";
-  case ErgoIHOP:              return "IHOP";
-  default:
-    ShouldNotReachHere();
-    // Keep the Windows compiler happy
-    return NULL;
-  }
-}
--- a/src/share/vm/gc/g1/g1ErgoVerbose.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,204 +0,0 @@
-/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef SHARE_VM_GC_G1_G1ERGOVERBOSE_HPP
-#define SHARE_VM_GC_G1_G1ERGOVERBOSE_HPP
-
-#include "memory/allocation.hpp"
-#include "utilities/debug.hpp"
-
-// The log of G1's heuristic decisions comprises of a series of
-// records which have a similar format in order to maintain
-// consistency across records and ultimately easier parsing of the
-// output, if we ever choose to do that. Each record consists of:
-// * A time stamp to be able to easily correlate each record with
-// other events.
-// * A unique string to allow us to easily identify such records.
-// * The name of the heuristic the record corresponds to.
-// * An action string which describes the action that G1 did or is
-// about to do.
-// * An optional reason string which describes the reason for the
-// action.
-// * An optional number of name/value pairs which contributed to the
-// decision to take the action described in the record.
-//
-// Each record is associated with a "tag" which is the combination of
-// the heuristic the record corresponds to, as well as the min level
-// of verboseness at which the record should be printed. The tag is
-// checked against the current settings to determine whether the record
-// should be printed or not.
-
-// The available verboseness levels.
-typedef enum {
-  // Determine which part of the tag is occupied by the level.
-  ErgoLevelShift = 8,
-  ErgoLevelMask = ~((1 << ErgoLevelShift) - 1),
-
-  // ErgoLow is 0 so that we don't have to explicitly or a heuristic
-  // id with ErgoLow to keep its use simpler.
-  ErgoLow = 0,
-  ErgoHigh = 1 << ErgoLevelShift
-} ErgoLevel;
-
-// The available heuristics.
-typedef enum {
-  // Determines which part of the tag is occupied by the heuristic id.
-  ErgoHeuristicMask = ~ErgoLevelMask,
-
-  ErgoHeapSizing = 0,
-  ErgoCSetConstruction,
-  ErgoConcCycles,
-  ErgoMixedGCs,
-  ErgoTiming,
-  ErgoIHOP,
-
-  ErgoHeuristicNum
-} ErgoHeuristic;
-
-class G1ErgoVerbose : AllStatic {
-private:
-  // Determines the minimum verboseness level at which records will be
-  // printed.
-  static ErgoLevel _level;
-  // Determines which heuristics are currently enabled.
-  static bool _enabled[ErgoHeuristicNum];
-
-  static ErgoLevel extract_level(int tag) {
-    return (ErgoLevel) (tag & ErgoLevelMask);
-  }
-
-  static ErgoHeuristic extract_heuristic(int tag) {
-    return (ErgoHeuristic) (tag & ErgoHeuristicMask);
-  }
-
-public:
-  // Needs to be explicitly called at GC initialization.
-  static void initialize();
-
-  static void set_level(ErgoLevel level);
-  static void set_enabled(ErgoHeuristic h, bool enabled);
-  // It is applied to all heuristics.
-  static void set_enabled(bool enabled);
-
-  static bool enabled(int tag) {
-    ErgoLevel level = extract_level(tag);
-    ErgoHeuristic n = extract_heuristic(tag);
-    return level <= _level && _enabled[n];
-  }
-
-  // Extract the heuristic id from the tag and return a string with
-  // its name.
-  static const char* to_string(int tag);
-};
-
-// The macros below generate the format string for values of different
-// types and/or metrics.
-
-// The reason for the action is optional and is handled specially: the
-// reason string is concatenated here so it's not necessary to pass it
-// as a parameter.
-#define ergo_format_reason(_reason_) ", reason: " _reason_
-
-// Single parameter format strings
-#define ergo_format_str(_name_)      ", " _name_ ": %s"
-#define ergo_format_region(_name_)   ", " _name_ ": %u regions"
-#define ergo_format_byte(_name_)     ", " _name_ ": " SIZE_FORMAT " bytes"
-#define ergo_format_double(_name_)   ", " _name_ ": %1.2f"
-#define ergo_format_perc(_name_)     ", " _name_ ": %1.2f %%"
-#define ergo_format_ms(_name_)       ", " _name_ ": %1.2f ms"
-#define ergo_format_size(_name_)     ", " _name_ ": " SIZE_FORMAT
-
-// Double parameter format strings
-#define ergo_format_byte_perc(_name_)                                   \
-                             ", " _name_ ": " SIZE_FORMAT " bytes (%1.2f %%)"
-
-// Generates the format string
-#define ergo_format(_extra_format_)                           \
-  " %1.3f: [G1Ergonomics (%s) %s" _extra_format_ "]"
-
-// Conditionally, prints an ergonomic decision record. _extra_format_
-// is the format string for the optional items we'd like to print
-// (i.e., the decision's reason and any associated values). This
-// string should be built up using the ergo_*_format macros (see
-// above) to ensure consistency.
-//
-// Since we cannot rely on the compiler supporting variable argument
-// macros, this macro accepts a fixed number of arguments and passes
-// them to the print method. For convenience, we have wrapper macros
-// below which take a specific number of arguments and set the rest to
-// a default value.
-#define ergo_verbose_common(_tag_, _action_, _extra_format_,                \
-                            _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_) \
-  do {                                                                      \
-    if (G1ErgoVerbose::enabled((_tag_))) {                                  \
-      gclog_or_tty->print_cr(ergo_format(_extra_format_),                   \
-                             os::elapsedTime(),                             \
-                             G1ErgoVerbose::to_string((_tag_)),             \
-                             (_action_),                                    \
-                             (_arg0_), (_arg1_), (_arg2_),                  \
-                             (_arg3_), (_arg4_), (_arg5_));                 \
-    }                                                                       \
-  } while (0)
-
-
-#define ergo_verbose6(_tag_, _action_, _extra_format_,                  \
-                      _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_)   \
-  ergo_verbose_common(_tag_, _action_, _extra_format_,                  \
-                      _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, _arg5_)
-
-#define ergo_verbose5(_tag_, _action_, _extra_format_,                  \
-                      _arg0_, _arg1_, _arg2_, _arg3_, _arg4_)           \
-  ergo_verbose6(_tag_, _action_, _extra_format_ "%s",                   \
-                _arg0_, _arg1_, _arg2_, _arg3_, _arg4_, "")
-
-#define ergo_verbose4(_tag_, _action_, _extra_format_,                  \
-                      _arg0_, _arg1_, _arg2_, _arg3_)                   \
-  ergo_verbose5(_tag_, _action_, _extra_format_ "%s",                   \
-                _arg0_, _arg1_, _arg2_, _arg3_, "")
-
-#define ergo_verbose3(_tag_, _action_, _extra_format_,                  \
-                      _arg0_, _arg1_, _arg2_)                           \
-  ergo_verbose4(_tag_, _action_, _extra_format_ "%s",                   \
-                _arg0_, _arg1_, _arg2_, "")
-
-#define ergo_verbose2(_tag_, _action_, _extra_format_,                  \
-                      _arg0_, _arg1_)                                   \
-  ergo_verbose3(_tag_, _action_, _extra_format_ "%s",                   \
-                _arg0_, _arg1_, "")
-
-#define ergo_verbose1(_tag_, _action_, _extra_format_,                  \
-                      _arg0_)                                           \
-  ergo_verbose2(_tag_, _action_, _extra_format_ "%s",                   \
-                _arg0_, "")
-
-
-#define ergo_verbose0(_tag_, _action_, _extra_format_)                  \
-  ergo_verbose1(_tag_, _action_, _extra_format_ "%s",                   \
-                "")
-
-#define ergo_verbose(_tag_, _action_)                                   \
-  ergo_verbose0(_tag_, _action_, "")
-
-
-#endif // SHARE_VM_GC_G1_G1ERGOVERBOSE_HPP
--- a/src/share/vm/gc/g1/g1EvacStats.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1EvacStats.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -26,91 +26,97 @@
 #include "memory/allocation.inline.hpp"
 #include "gc/g1/g1EvacStats.hpp"
 #include "gc/shared/gcId.hpp"
+#include "logging/log.hpp"
 #include "trace/tracing.hpp"
 
 void G1EvacStats::adjust_desired_plab_sz() {
-  if (PrintPLAB) {
-    gclog_or_tty->print(" (allocated = " SIZE_FORMAT " wasted = " SIZE_FORMAT " "
+  if (!ResizePLAB) {
+    log_debug(gc, plab)(" (allocated = " SIZE_FORMAT " wasted = " SIZE_FORMAT " "
                         "unused = " SIZE_FORMAT " used = " SIZE_FORMAT " "
                         "undo_waste = " SIZE_FORMAT " region_end_waste = " SIZE_FORMAT " "
                         "regions filled = %u direct_allocated = " SIZE_FORMAT " "
                         "failure_used = " SIZE_FORMAT " failure_waste = " SIZE_FORMAT ") ",
                         _allocated, _wasted, _unused, used(), _undo_wasted, _region_end_waste,
                         _regions_filled, _direct_allocated, _failure_used, _failure_waste);
+    // Clear accumulators for next round.
+    reset();
+    return;
   }
 
-  if (ResizePLAB) {
+  assert(is_object_aligned(max_size()) && min_size() <= max_size(),
+         "PLAB clipping computation may be incorrect");
 
-    assert(is_object_aligned(max_size()) && min_size() <= max_size(),
-           "PLAB clipping computation may be incorrect");
+  if (_allocated == 0) {
+    assert((_unused == 0),
+           "Inconsistency in PLAB stats: "
+           "_allocated: " SIZE_FORMAT ", "
+           "_wasted: " SIZE_FORMAT ", "
+           "_region_end_waste: " SIZE_FORMAT ", "
+           "_unused: " SIZE_FORMAT ", "
+           "_used  : " SIZE_FORMAT,
+           _allocated, _wasted, _region_end_waste, _unused, used());
+    _allocated = 1;
+  }
+  // The size of the PLAB caps the amount of space that can be wasted at the
+  // end of the collection. In the worst case the last PLAB could be completely
+  // empty.
+  // This allows us to calculate the new PLAB size to achieve the
+  // TargetPLABWastePct given the latest memory usage and that the last buffer
+  // will be G1LastPLABAverageOccupancy full.
+  //
+  // E.g. assume that if in the current GC 100 words were allocated and a
+  // TargetPLABWastePct of 10 had been set.
+  //
+  // So we could waste up to 10 words to meet that percentage. Given that we
+  // also assume that that buffer is typically half-full, the new desired PLAB
+  // size is set to 20 words.
+  //
+  // The amount of allocation performed should be independent of the number of
+  // threads, so should the maximum waste we can spend in total. So if
+  // we used n threads to allocate, each of them can spend maximum waste/n words in
+  // a first rough approximation. The number of threads only comes into play later
+  // when actually retrieving the actual desired PLAB size.
+  //
+  // After calculating this optimal PLAB size the algorithm applies the usual
+  // exponential decaying average over this value to guess the next PLAB size.
+  //
+  // We account region end waste fully to PLAB allocation (in the calculation of
+  // what we consider as "used_for_waste_calculation" below). This is not
+  // completely fair, but is a conservative assumption because PLABs may be sized
+  // flexibly while we cannot adjust inline allocations.
+  // Allocation during GC will try to minimize region end waste so this impact
+  // should be minimal.
+  //
+  // We need to cover overflow when calculating the amount of space actually used
+  // by objects in PLABs when subtracting the region end waste.
+  // Region end waste may be higher than actual allocation. This may occur if many
+  // threads do not allocate anything but a few rather large objects. In this
+  // degenerate case the PLAB size would simply quickly tend to minimum PLAB size,
+  // which is an okay reaction.
+  size_t const used_for_waste_calculation = used() > _region_end_waste ? used() - _region_end_waste : 0;
 
-    if (_allocated == 0) {
-      assert((_unused == 0),
-             "Inconsistency in PLAB stats: "
-             "_allocated: " SIZE_FORMAT ", "
-             "_wasted: " SIZE_FORMAT ", "
-             "_region_end_waste: " SIZE_FORMAT ", "
-             "_unused: " SIZE_FORMAT ", "
-             "_used  : " SIZE_FORMAT,
-             _allocated, _wasted, _region_end_waste, _unused, used());
-      _allocated = 1;
-    }
-    // The size of the PLAB caps the amount of space that can be wasted at the
-    // end of the collection. In the worst case the last PLAB could be completely
-    // empty.
-    // This allows us to calculate the new PLAB size to achieve the
-    // TargetPLABWastePct given the latest memory usage and that the last buffer
-    // will be G1LastPLABAverageOccupancy full.
-    //
-    // E.g. assume that if in the current GC 100 words were allocated and a
-    // TargetPLABWastePct of 10 had been set.
-    //
-    // So we could waste up to 10 words to meet that percentage. Given that we
-    // also assume that that buffer is typically half-full, the new desired PLAB
-    // size is set to 20 words.
-    //
-    // The amount of allocation performed should be independent of the number of
-    // threads, so should the maximum waste we can spend in total. So if
-    // we used n threads to allocate, each of them can spend maximum waste/n words in
-    // a first rough approximation. The number of threads only comes into play later
-    // when actually retrieving the actual desired PLAB size.
-    //
-    // After calculating this optimal PLAB size the algorithm applies the usual
-    // exponential decaying average over this value to guess the next PLAB size.
-    //
-    // We account region end waste fully to PLAB allocation (in the calculation of
-    // what we consider as "used_for_waste_calculation" below). This is not
-    // completely fair, but is a conservative assumption because PLABs may be sized
-    // flexibly while we cannot adjust inline allocations.
-    // Allocation during GC will try to minimize region end waste so this impact
-    // should be minimal.
-    //
-    // We need to cover overflow when calculating the amount of space actually used
-    // by objects in PLABs when subtracting the region end waste.
-    // Region end waste may be higher than actual allocation. This may occur if many
-    // threads do not allocate anything but a few rather large objects. In this
-    // degenerate case the PLAB size would simply quickly tend to minimum PLAB size,
-    // which is an okay reaction.
-    size_t const used_for_waste_calculation = used() > _region_end_waste ? used() - _region_end_waste : 0;
+  size_t const total_waste_allowed = used_for_waste_calculation * TargetPLABWastePct;
+  size_t const cur_plab_sz = (size_t)((double)total_waste_allowed / G1LastPLABAverageOccupancy);
+  // Take historical weighted average
+  _filter.sample(cur_plab_sz);
+  // Clip from above and below, and align to object boundary
+  size_t plab_sz;
+  plab_sz = MAX2(min_size(), (size_t)_filter.average());
+  plab_sz = MIN2(max_size(), plab_sz);
+  plab_sz = align_object_size(plab_sz);
+  // Latch the result
+  _desired_net_plab_sz = plab_sz;
 
-    size_t const total_waste_allowed = used_for_waste_calculation * TargetPLABWastePct;
-    size_t const cur_plab_sz = (size_t)((double)total_waste_allowed / G1LastPLABAverageOccupancy);
-    // Take historical weighted average
-    _filter.sample(cur_plab_sz);
-    // Clip from above and below, and align to object boundary
-    size_t plab_sz;
-    plab_sz = MAX2(min_size(), (size_t)_filter.average());
-    plab_sz = MIN2(max_size(), plab_sz);
-    plab_sz = align_object_size(plab_sz);
-    // Latch the result
-    _desired_net_plab_sz = plab_sz;
-    if (PrintPLAB) {
-      gclog_or_tty->print(" (plab_sz = " SIZE_FORMAT " desired_plab_sz = " SIZE_FORMAT ") ", cur_plab_sz, plab_sz);
-    }
-  }
-  if (PrintPLAB) {
-    gclog_or_tty->cr();
-  }
+  log_debug(gc, plab)(" (allocated = " SIZE_FORMAT " wasted = " SIZE_FORMAT " "
+                      "unused = " SIZE_FORMAT " used = " SIZE_FORMAT " "
+                      "undo_waste = " SIZE_FORMAT " region_end_waste = " SIZE_FORMAT " "
+                      "regions filled = %u direct_allocated = " SIZE_FORMAT " "
+                      "failure_used = " SIZE_FORMAT " failure_waste = " SIZE_FORMAT ") "
+                      " (plab_sz = " SIZE_FORMAT " desired_plab_sz = " SIZE_FORMAT ")",
+                      _allocated, _wasted, _unused, used(), _undo_wasted, _region_end_waste,
+                      _regions_filled, _direct_allocated, _failure_used, _failure_waste,
+                      cur_plab_sz, plab_sz);
+
   // Clear accumulators for next round.
   reset();
 }
--- a/src/share/vm/gc/g1/g1GCPhaseTimes.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1GCPhaseTimes.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -26,10 +26,10 @@
 #include "gc/g1/concurrentG1Refine.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1GCPhaseTimes.hpp"
-#include "gc/g1/g1Log.hpp"
 #include "gc/g1/g1StringDedup.hpp"
 #include "gc/g1/workerDataArray.inline.hpp"
 #include "memory/allocation.hpp"
+#include "logging/log.hpp"
 #include "runtime/os.hpp"
 
 // Helper class for avoiding interleaved logging
@@ -73,66 +73,60 @@
     va_end(ap);
   }
 
-  void print_cr() {
-    gclog_or_tty->print_cr("%s", _buffer);
+  const char* to_string() {
     _cur = _indent_level * INDENT_CHARS;
-  }
-
-  void append_and_print_cr(const char* format, ...)  ATTRIBUTE_PRINTF(2, 3) {
-    va_list ap;
-    va_start(ap, format);
-    vappend(format, ap);
-    va_end(ap);
-    print_cr();
+    return _buffer;
   }
 };
 
+static const char* Indents[4] = {"", "   ", "      ", "         "};
+
 G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads) :
   _max_gc_threads(max_gc_threads)
 {
   assert(max_gc_threads > 0, "Must have some GC threads");
 
-  _gc_par_phases[GCWorkerStart] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Start (ms)", false, G1Log::LevelFiner, 2);
-  _gc_par_phases[ExtRootScan] = new WorkerDataArray<double>(max_gc_threads, "Ext Root Scanning (ms)", true, G1Log::LevelFiner, 2);
+  _gc_par_phases[GCWorkerStart] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Start:", false, 2);
+  _gc_par_phases[ExtRootScan] = new WorkerDataArray<double>(max_gc_threads, "Ext Root Scanning:", true, 2);
 
   // Root scanning phases
-  _gc_par_phases[ThreadRoots] = new WorkerDataArray<double>(max_gc_threads, "Thread Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[StringTableRoots] = new WorkerDataArray<double>(max_gc_threads, "StringTable Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[UniverseRoots] = new WorkerDataArray<double>(max_gc_threads, "Universe Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[JNIRoots] = new WorkerDataArray<double>(max_gc_threads, "JNI Handles Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[ObjectSynchronizerRoots] = new WorkerDataArray<double>(max_gc_threads, "ObjectSynchronizer Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[FlatProfilerRoots] = new WorkerDataArray<double>(max_gc_threads, "FlatProfiler Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[ManagementRoots] = new WorkerDataArray<double>(max_gc_threads, "Management Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[SystemDictionaryRoots] = new WorkerDataArray<double>(max_gc_threads, "SystemDictionary Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[CLDGRoots] = new WorkerDataArray<double>(max_gc_threads, "CLDG Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[JVMTIRoots] = new WorkerDataArray<double>(max_gc_threads, "JVMTI Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[CMRefRoots] = new WorkerDataArray<double>(max_gc_threads, "CM RefProcessor Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[WaitForStrongCLD] = new WorkerDataArray<double>(max_gc_threads, "Wait For Strong CLD (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[WeakCLDRoots] = new WorkerDataArray<double>(max_gc_threads, "Weak CLD Roots (ms)", true, G1Log::LevelFinest, 3);
-  _gc_par_phases[SATBFiltering] = new WorkerDataArray<double>(max_gc_threads, "SATB Filtering (ms)", true, G1Log::LevelFinest, 3);
+  _gc_par_phases[ThreadRoots] = new WorkerDataArray<double>(max_gc_threads, "Thread Roots:", true, 3);
+  _gc_par_phases[StringTableRoots] = new WorkerDataArray<double>(max_gc_threads, "StringTable Roots:", true, 3);
+  _gc_par_phases[UniverseRoots] = new WorkerDataArray<double>(max_gc_threads, "Universe Roots:", true, 3);
+  _gc_par_phases[JNIRoots] = new WorkerDataArray<double>(max_gc_threads, "JNI Handles Roots:", true, 3);
+  _gc_par_phases[ObjectSynchronizerRoots] = new WorkerDataArray<double>(max_gc_threads, "ObjectSynchronizer Roots:", true, 3);
+  _gc_par_phases[FlatProfilerRoots] = new WorkerDataArray<double>(max_gc_threads, "FlatProfiler Roots:", true, 3);
+  _gc_par_phases[ManagementRoots] = new WorkerDataArray<double>(max_gc_threads, "Management Roots:", true, 3);
+  _gc_par_phases[SystemDictionaryRoots] = new WorkerDataArray<double>(max_gc_threads, "SystemDictionary Roots:", true, 3);
+  _gc_par_phases[CLDGRoots] = new WorkerDataArray<double>(max_gc_threads, "CLDG Roots:", true, 3);
+  _gc_par_phases[JVMTIRoots] = new WorkerDataArray<double>(max_gc_threads, "JVMTI Roots:", true, 3);
+  _gc_par_phases[CMRefRoots] = new WorkerDataArray<double>(max_gc_threads, "CM RefProcessor Roots:", true, 3);
+  _gc_par_phases[WaitForStrongCLD] = new WorkerDataArray<double>(max_gc_threads, "Wait For Strong CLD:", true, 3);
+  _gc_par_phases[WeakCLDRoots] = new WorkerDataArray<double>(max_gc_threads, "Weak CLD Roots:", true, 3);
+  _gc_par_phases[SATBFiltering] = new WorkerDataArray<double>(max_gc_threads, "SATB Filtering:", true, 3);
 
-  _gc_par_phases[UpdateRS] = new WorkerDataArray<double>(max_gc_threads, "Update RS (ms)", true, G1Log::LevelFiner, 2);
-  _gc_par_phases[ScanHCC] = new WorkerDataArray<double>(max_gc_threads, "Scan HCC (ms)", true, G1Log::LevelFiner, 3);
+  _gc_par_phases[UpdateRS] = new WorkerDataArray<double>(max_gc_threads, "Update RS:", true, 2);
+  _gc_par_phases[ScanHCC] = new WorkerDataArray<double>(max_gc_threads, "Scan HCC:", true, 3);
   _gc_par_phases[ScanHCC]->set_enabled(ConcurrentG1Refine::hot_card_cache_enabled());
-  _gc_par_phases[ScanRS] = new WorkerDataArray<double>(max_gc_threads, "Scan RS (ms)", true, G1Log::LevelFiner, 2);
-  _gc_par_phases[CodeRoots] = new WorkerDataArray<double>(max_gc_threads, "Code Root Scanning (ms)", true, G1Log::LevelFiner, 2);
-  _gc_par_phases[ObjCopy] = new WorkerDataArray<double>(max_gc_threads, "Object Copy (ms)", true, G1Log::LevelFiner, 2);
-  _gc_par_phases[Termination] = new WorkerDataArray<double>(max_gc_threads, "Termination (ms)", true, G1Log::LevelFiner, 2);
-  _gc_par_phases[GCWorkerTotal] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Total (ms)", true, G1Log::LevelFiner, 2);
-  _gc_par_phases[GCWorkerEnd] = new WorkerDataArray<double>(max_gc_threads, "GC Worker End (ms)", false, G1Log::LevelFiner, 2);
-  _gc_par_phases[Other] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Other (ms)", true, G1Log::LevelFiner, 2);
+  _gc_par_phases[ScanRS] = new WorkerDataArray<double>(max_gc_threads, "Scan RS:", true, 2);
+  _gc_par_phases[CodeRoots] = new WorkerDataArray<double>(max_gc_threads, "Code Root Scanning:", true, 2);
+  _gc_par_phases[ObjCopy] = new WorkerDataArray<double>(max_gc_threads, "Object Copy:", true, 2);
+  _gc_par_phases[Termination] = new WorkerDataArray<double>(max_gc_threads, "Termination:", true, 2);
+  _gc_par_phases[GCWorkerTotal] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Total:", true, 2);
+  _gc_par_phases[GCWorkerEnd] = new WorkerDataArray<double>(max_gc_threads, "GC Worker End:", false, 2);
+  _gc_par_phases[Other] = new WorkerDataArray<double>(max_gc_threads, "GC Worker Other:", true, 2);
 
-  _update_rs_processed_buffers = new WorkerDataArray<size_t>(max_gc_threads, "Processed Buffers", true, G1Log::LevelFiner, 3);
+  _update_rs_processed_buffers = new WorkerDataArray<size_t>(max_gc_threads, "Processed Buffers:", true, 3);
   _gc_par_phases[UpdateRS]->link_thread_work_items(_update_rs_processed_buffers);
 
-  _termination_attempts = new WorkerDataArray<size_t>(max_gc_threads, "Termination Attempts", true, G1Log::LevelFinest, 3);
+  _termination_attempts = new WorkerDataArray<size_t>(max_gc_threads, "Termination Attempts:", true, 3);
   _gc_par_phases[Termination]->link_thread_work_items(_termination_attempts);
 
-  _gc_par_phases[StringDedupQueueFixup] = new WorkerDataArray<double>(max_gc_threads, "Queue Fixup (ms)", true, G1Log::LevelFiner, 2);
-  _gc_par_phases[StringDedupTableFixup] = new WorkerDataArray<double>(max_gc_threads, "Table Fixup (ms)", true, G1Log::LevelFiner, 2);
+  _gc_par_phases[StringDedupQueueFixup] = new WorkerDataArray<double>(max_gc_threads, "Queue Fixup:", true, 2);
+  _gc_par_phases[StringDedupTableFixup] = new WorkerDataArray<double>(max_gc_threads, "Table Fixup:", true, 2);
 
-  _gc_par_phases[RedirtyCards] = new WorkerDataArray<double>(max_gc_threads, "Parallel Redirty", true, G1Log::LevelFinest, 3);
-  _redirtied_cards = new WorkerDataArray<size_t>(max_gc_threads, "Redirtied Cards", true, G1Log::LevelFinest, 3);
+  _gc_par_phases[RedirtyCards] = new WorkerDataArray<double>(max_gc_threads, "Parallel Redirty", true, 3);
+  _redirtied_cards = new WorkerDataArray<size_t>(max_gc_threads, "Redirtied Cards:", true, 3);
   _gc_par_phases[RedirtyCards]->link_thread_work_items(_redirtied_cards);
 }
 
@@ -173,16 +167,8 @@
   }
 }
 
-void G1GCPhaseTimes::print_stats(int level, const char* str, double value) {
-  LineBuffer(level).append_and_print_cr("[%s: %.1lf ms]", str, value);
-}
-
-void G1GCPhaseTimes::print_stats(int level, const char* str, size_t value) {
-  LineBuffer(level).append_and_print_cr("[%s: " SIZE_FORMAT "]", str, value);
-}
-
-void G1GCPhaseTimes::print_stats(int level, const char* str, double value, uint workers) {
-  LineBuffer(level).append_and_print_cr("[%s: %.1lf ms, GC Workers: %u]", str, value, workers);
+void G1GCPhaseTimes::print_stats(const char* indent, const char* str, double value) {
+  log_debug(gc, phases)("%s%s: %.1lf ms", indent, str, value);
 }
 
 double G1GCPhaseTimes::accounted_time_ms() {
@@ -284,10 +270,6 @@
   void print(G1GCPhaseTimes::GCParPhases phase_id) {
     WorkerDataArray<double>* phase = _phase_times->_gc_par_phases[phase_id];
 
-    if (phase->_log_level > G1Log::level() || !phase->_enabled) {
-      return;
-    }
-
     if (phase->_length == 1) {
       print_single_length(phase_id, phase);
     } else {
@@ -295,69 +277,71 @@
     }
   }
 
+
  private:
-
   void print_single_length(G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<double>* phase) {
     // No need for min, max, average and sum for only one worker
-    LineBuffer buf(phase->_indent_level);
-    buf.append_and_print_cr("[%s:  %.1lf]", phase->_title, _phase_times->get_time_ms(phase_id, 0));
+    log_debug(gc, phases)("%s%s:  %.1lf", Indents[phase->_indent_level], phase->_title, _phase_times->get_time_ms(phase_id, 0));
 
-    if (phase->_thread_work_items != NULL) {
-      LineBuffer buf2(phase->_thread_work_items->_indent_level);
-      buf2.append_and_print_cr("[%s:  " SIZE_FORMAT "]", phase->_thread_work_items->_title, _phase_times->sum_thread_work_items(phase_id));
+    WorkerDataArray<size_t>* work_items = phase->_thread_work_items;
+    if (work_items != NULL) {
+      log_debug(gc, phases)("%s%s:  " SIZE_FORMAT, Indents[work_items->_indent_level], work_items->_title, _phase_times->sum_thread_work_items(phase_id));
     }
   }
 
-  void print_time_values(LineBuffer& buf, G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<double>* phase) {
-    uint active_length = _phase_times->_active_gc_threads;
-    for (uint i = 0; i < active_length; ++i) {
-      buf.append("  %.1lf", _phase_times->get_time_ms(phase_id, i));
+  void print_time_values(const char* indent, G1GCPhaseTimes::GCParPhases phase_id) {
+    if (log_is_enabled(Trace, gc)) {
+      LineBuffer buf(0);
+      uint active_length = _phase_times->_active_gc_threads;
+      for (uint i = 0; i < active_length; ++i) {
+        buf.append(" %4.1lf", _phase_times->get_time_ms(phase_id, i));
+      }
+      const char* line = buf.to_string();
+      log_trace(gc, phases)("%s%-25s%s", indent, "", line);
     }
-    buf.print_cr();
   }
 
-  void print_count_values(LineBuffer& buf, G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<size_t>* thread_work_items) {
-    uint active_length = _phase_times->_active_gc_threads;
-    for (uint i = 0; i < active_length; ++i) {
-      buf.append("  " SIZE_FORMAT, _phase_times->get_thread_work_item(phase_id, i));
+  void print_count_values(const char* indent, G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<size_t>* thread_work_items) {
+    if (log_is_enabled(Trace, gc)) {
+      LineBuffer buf(0);
+      uint active_length = _phase_times->_active_gc_threads;
+      for (uint i = 0; i < active_length; ++i) {
+        buf.append("  " SIZE_FORMAT, _phase_times->get_thread_work_item(phase_id, i));
+      }
+      const char* line = buf.to_string();
+      log_trace(gc, phases)("%s%-25s%s", indent, "", line);
     }
-    buf.print_cr();
   }
 
   void print_thread_work_items(G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<size_t>* thread_work_items) {
-    LineBuffer buf(thread_work_items->_indent_level);
-    buf.append("[%s:", thread_work_items->_title);
-
-    if (G1Log::finest()) {
-      print_count_values(buf, phase_id, thread_work_items);
-    }
+    const char* indent = Indents[thread_work_items->_indent_level];
 
     assert(thread_work_items->_print_sum, "%s does not have print sum true even though it is a count", thread_work_items->_title);
 
-    buf.append_and_print_cr(" Min: " SIZE_FORMAT ", Avg: %.1lf, Max: " SIZE_FORMAT ", Diff: " SIZE_FORMAT ", Sum: " SIZE_FORMAT "]",
+    log_debug(gc, phases)("%s%-25s Min: " SIZE_FORMAT ", Avg: %4.1lf, Max: " SIZE_FORMAT ", Diff: " SIZE_FORMAT ", Sum: " SIZE_FORMAT,
+        indent, thread_work_items->_title,
         _phase_times->min_thread_work_items(phase_id), _phase_times->average_thread_work_items(phase_id), _phase_times->max_thread_work_items(phase_id),
         _phase_times->max_thread_work_items(phase_id) - _phase_times->min_thread_work_items(phase_id), _phase_times->sum_thread_work_items(phase_id));
+
+    print_count_values(indent, phase_id, thread_work_items);
   }
 
   void print_multi_length(G1GCPhaseTimes::GCParPhases phase_id, WorkerDataArray<double>* phase) {
-    LineBuffer buf(phase->_indent_level);
-    buf.append("[%s:", phase->_title);
+    const char* indent = Indents[phase->_indent_level];
 
-    if (G1Log::finest()) {
-      print_time_values(buf, phase_id, phase);
+    if (phase->_print_sum) {
+      log_debug(gc, phases)("%s%-25s Min: %4.1lf, Avg: %4.1lf, Max: %4.1lf, Diff: %4.1lf, Sum: %4.1lf",
+          indent, phase->_title,
+          _phase_times->min_time_ms(phase_id), _phase_times->average_time_ms(phase_id), _phase_times->max_time_ms(phase_id),
+          _phase_times->max_time_ms(phase_id) - _phase_times->min_time_ms(phase_id), _phase_times->sum_time_ms(phase_id));
+    } else {
+      log_debug(gc, phases)("%s%-25s Min: %4.1lf, Avg: %4.1lf, Max: %4.1lf, Diff: %4.1lf",
+          indent, phase->_title,
+          _phase_times->min_time_ms(phase_id), _phase_times->average_time_ms(phase_id), _phase_times->max_time_ms(phase_id),
+          _phase_times->max_time_ms(phase_id) - _phase_times->min_time_ms(phase_id));
     }
 
-    buf.append(" Min: %.1lf, Avg: %.1lf, Max: %.1lf, Diff: %.1lf",
-        _phase_times->min_time_ms(phase_id), _phase_times->average_time_ms(phase_id), _phase_times->max_time_ms(phase_id),
-        _phase_times->max_time_ms(phase_id) - _phase_times->min_time_ms(phase_id));
-
-    if (phase->_print_sum) {
-      // for things like the start and end times the sum is not
-      // that relevant
-      buf.append(", Sum: %.1lf", _phase_times->sum_time_ms(phase_id));
-    }
-
-    buf.append_and_print_cr("]");
+    print_time_values(indent, phase_id);
 
     if (phase->_thread_work_items != NULL) {
       print_thread_work_items(phase_id, phase->_thread_work_items);
@@ -371,67 +355,59 @@
   G1GCParPhasePrinter par_phase_printer(this);
 
   if (_root_region_scan_wait_time_ms > 0.0) {
-    print_stats(1, "Root Region Scan Waiting", _root_region_scan_wait_time_ms);
+    print_stats(Indents[1], "Root Region Scan Waiting", _root_region_scan_wait_time_ms);
   }
 
-  print_stats(1, "Parallel Time", _cur_collection_par_time_ms, _active_gc_threads);
+  print_stats(Indents[1], "Parallel Time", _cur_collection_par_time_ms);
   for (int i = 0; i <= GCMainParPhasesLast; i++) {
     par_phase_printer.print((GCParPhases) i);
   }
 
-  print_stats(1, "Code Root Fixup", _cur_collection_code_root_fixup_time_ms);
-  print_stats(1, "Code Root Purge", _cur_strong_code_root_purge_time_ms);
+  print_stats(Indents[1], "Code Root Fixup", _cur_collection_code_root_fixup_time_ms);
+  print_stats(Indents[1], "Code Root Purge", _cur_strong_code_root_purge_time_ms);
   if (G1StringDedup::is_enabled()) {
-    print_stats(1, "String Dedup Fixup", _cur_string_dedup_fixup_time_ms, _active_gc_threads);
+    print_stats(Indents[1], "String Dedup Fixup", _cur_string_dedup_fixup_time_ms);
     for (int i = StringDedupPhasesFirst; i <= StringDedupPhasesLast; i++) {
       par_phase_printer.print((GCParPhases) i);
     }
   }
-  print_stats(1, "Clear CT", _cur_clear_ct_time_ms);
-  print_stats(1, "Expand Heap After Collection", _cur_expand_heap_time_ms);
-
+  print_stats(Indents[1], "Clear CT", _cur_clear_ct_time_ms);
+  print_stats(Indents[1], "Expand Heap After Collection", _cur_expand_heap_time_ms);
   double misc_time_ms = pause_time_sec * MILLIUNITS - accounted_time_ms();
-  print_stats(1, "Other", misc_time_ms);
+  print_stats(Indents[1], "Other", misc_time_ms);
   if (_cur_verify_before_time_ms > 0.0) {
-    print_stats(2, "Verify Before", _cur_verify_before_time_ms);
+    print_stats(Indents[2], "Verify Before", _cur_verify_before_time_ms);
   }
   if (G1CollectedHeap::heap()->evacuation_failed()) {
     double evac_fail_handling = _cur_evac_fail_recalc_used + _cur_evac_fail_remove_self_forwards +
       _cur_evac_fail_restore_remsets;
-    print_stats(2, "Evacuation Failure", evac_fail_handling);
-    if (G1Log::finest()) {
-      print_stats(3, "Recalculate Used", _cur_evac_fail_recalc_used);
-      print_stats(3, "Remove Self Forwards", _cur_evac_fail_remove_self_forwards);
-      print_stats(3, "Restore RemSet", _cur_evac_fail_restore_remsets);
-    }
+    print_stats(Indents[2], "Evacuation Failure", evac_fail_handling);
+    log_trace(gc, phases)("%sRecalculate Used: %.1lf ms", Indents[3], _cur_evac_fail_recalc_used);
+    log_trace(gc, phases)("%sRemove Self Forwards: %.1lf ms", Indents[3], _cur_evac_fail_remove_self_forwards);
+    log_trace(gc, phases)("%sRestore RemSet: %.1lf ms", Indents[3], _cur_evac_fail_restore_remsets);
   }
-  print_stats(2, "Choose CSet",
+  print_stats(Indents[2], "Choose CSet",
     (_recorded_young_cset_choice_time_ms +
     _recorded_non_young_cset_choice_time_ms));
-  print_stats(2, "Ref Proc", _cur_ref_proc_time_ms);
-  print_stats(2, "Ref Enq", _cur_ref_enq_time_ms);
-  print_stats(2, "Redirty Cards", _recorded_redirty_logged_cards_time_ms);
+  print_stats(Indents[2], "Ref Proc", _cur_ref_proc_time_ms);
+  print_stats(Indents[2], "Ref Enq", _cur_ref_enq_time_ms);
+  print_stats(Indents[2], "Redirty Cards", _recorded_redirty_logged_cards_time_ms);
   par_phase_printer.print(RedirtyCards);
   if (G1EagerReclaimHumongousObjects) {
-    print_stats(2, "Humongous Register", _cur_fast_reclaim_humongous_register_time_ms);
-    if (G1Log::finest()) {
-      print_stats(3, "Humongous Total", _cur_fast_reclaim_humongous_total);
-      print_stats(3, "Humongous Candidate", _cur_fast_reclaim_humongous_candidates);
-    }
-    print_stats(2, "Humongous Reclaim", _cur_fast_reclaim_humongous_time_ms);
-    if (G1Log::finest()) {
-      print_stats(3, "Humongous Reclaimed", _cur_fast_reclaim_humongous_reclaimed);
-    }
+    print_stats(Indents[2], "Humongous Register", _cur_fast_reclaim_humongous_register_time_ms);
+
+    log_trace(gc, phases)("%sHumongous Total: " SIZE_FORMAT, Indents[3], _cur_fast_reclaim_humongous_total);
+    log_trace(gc, phases)("%sHumongous Candidate: " SIZE_FORMAT, Indents[3], _cur_fast_reclaim_humongous_candidates);
+    print_stats(Indents[2], "Humongous Reclaim", _cur_fast_reclaim_humongous_time_ms);
+    log_trace(gc, phases)("%sHumongous Reclaimed: " SIZE_FORMAT, Indents[3], _cur_fast_reclaim_humongous_reclaimed);
   }
-  print_stats(2, "Free CSet",
+  print_stats(Indents[2], "Free CSet",
     (_recorded_young_free_cset_time_ms +
     _recorded_non_young_free_cset_time_ms));
-  if (G1Log::finest()) {
-    print_stats(3, "Young Free CSet", _recorded_young_free_cset_time_ms);
-    print_stats(3, "Non-Young Free CSet", _recorded_non_young_free_cset_time_ms);
-  }
+  log_trace(gc, phases)("%sYoung Free CSet: %.1lf ms", Indents[3], _recorded_young_free_cset_time_ms);
+  log_trace(gc, phases)("%sNon-Young Free CSet: %.1lf ms", Indents[3], _recorded_non_young_free_cset_time_ms);
   if (_cur_verify_after_time_ms > 0.0) {
-    print_stats(2, "Verify After", _cur_verify_after_time_ms);
+    print_stats(Indents[2], "Verify After", _cur_verify_after_time_ms);
   }
 }
 
--- a/src/share/vm/gc/g1/g1GCPhaseTimes.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1GCPhaseTimes.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -119,9 +119,7 @@
   double _cur_verify_after_time_ms;
 
   // Helper methods for detailed logging
-  void print_stats(int level, const char* str, double value);
-  void print_stats(int level, const char* str, size_t value);
-  void print_stats(int level, const char* str, double value, uint workers);
+  void print_stats(const char*, const char* str, double value);
 
   void note_gc_end();
 
--- a/src/share/vm/gc/g1/g1HRPrinter.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1HRPrinter.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -60,18 +60,6 @@
   return NULL;
 }
 
-const char* G1HRPrinter::phase_name(PhaseType phase) {
-  switch (phase) {
-    case StartGC:     return "StartGC";
-    case EndGC:       return "EndGC";
-    case StartFullGC: return "StartFullGC";
-    case EndFullGC:   return "EndFullGC";
-    default:          ShouldNotReachHere();
-  }
-  // trying to keep the Windows compiler happy
-  return NULL;
-}
-
 #define G1HR_PREFIX     " G1HR"
 
 void G1HRPrinter::print(ActionType action, RegionType type,
@@ -82,19 +70,19 @@
 
   if (type_str != NULL) {
     if (top != NULL) {
-      gclog_or_tty->print_cr(G1HR_PREFIX " %s(%s) " PTR_FORMAT " " PTR_FORMAT,
-                             action_str, type_str, p2i(bottom), p2i(top));
+      log_trace(gc, region)(G1HR_PREFIX " %s(%s) " PTR_FORMAT " " PTR_FORMAT,
+                            action_str, type_str, p2i(bottom), p2i(top));
     } else {
-      gclog_or_tty->print_cr(G1HR_PREFIX " %s(%s) " PTR_FORMAT,
-                             action_str, type_str, p2i(bottom));
+      log_trace(gc, region)(G1HR_PREFIX " %s(%s) " PTR_FORMAT,
+                            action_str, type_str, p2i(bottom));
     }
   } else {
     if (top != NULL) {
-      gclog_or_tty->print_cr(G1HR_PREFIX " %s " PTR_FORMAT " " PTR_FORMAT,
-                             action_str, p2i(bottom), p2i(top));
+      log_trace(gc, region)(G1HR_PREFIX " %s " PTR_FORMAT " " PTR_FORMAT,
+                            action_str, p2i(bottom), p2i(top));
     } else {
-      gclog_or_tty->print_cr(G1HR_PREFIX " %s " PTR_FORMAT,
-                             action_str, p2i(bottom));
+      log_trace(gc, region)(G1HR_PREFIX " %s " PTR_FORMAT,
+                            action_str, p2i(bottom));
     }
   }
 }
@@ -102,11 +90,6 @@
 void G1HRPrinter::print(ActionType action, HeapWord* bottom, HeapWord* end) {
   const char* action_str = action_name(action);
 
-  gclog_or_tty->print_cr(G1HR_PREFIX " %s [" PTR_FORMAT "," PTR_FORMAT "]",
-                         action_str, p2i(bottom), p2i(end));
+  log_trace(gc, region)(G1HR_PREFIX " %s [" PTR_FORMAT "," PTR_FORMAT "]",
+                        action_str, p2i(bottom), p2i(end));
 }
-
-void G1HRPrinter::print(PhaseType phase, size_t phase_num) {
-  const char* phase_str = phase_name(phase);
-  gclog_or_tty->print_cr(G1HR_PREFIX " #%s " SIZE_FORMAT, phase_str, phase_num);
-}
--- a/src/share/vm/gc/g1/g1HRPrinter.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1HRPrinter.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -26,6 +26,7 @@
 #define SHARE_VM_GC_G1_G1HRPRINTER_HPP
 
 #include "gc/g1/heapRegion.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.hpp"
 
 #define SKIP_RETIRED_FULL_REGIONS 1
@@ -55,19 +56,9 @@
     Archive
   } RegionType;
 
-  typedef enum {
-    StartGC,
-    EndGC,
-    StartFullGC,
-    EndFullGC
-  } PhaseType;
-
 private:
-  bool _active;
-
   static const char* action_name(ActionType action);
   static const char* region_type_name(RegionType type);
-  static const char* phase_name(PhaseType phase);
 
   // Print an action event. This version is used in most scenarios and
   // only prints the region's bottom. The parameters type and top are
@@ -79,18 +70,11 @@
   // bottom and end. Used for Commit / Uncommit events.
   static void print(ActionType action, HeapWord* bottom, HeapWord* end);
 
-  // Print a phase event.
-  static void print(PhaseType phase, size_t phase_num);
-
 public:
   // In some places we iterate over a list in order to generate output
   // for the list's elements. By exposing this we can avoid this
   // iteration if the printer is not active.
-  const bool is_active() { return _active; }
-
-  // Have to set this explicitly as we have to do this during the
-  // heap's initialize() method, not in the constructor.
-  void set_active(bool active) { _active = active; }
+  const bool is_active() { return log_is_enabled(Trace, gc, region); }
 
   // The methods below are convenient wrappers for the print() methods.
 
@@ -155,28 +139,6 @@
       print(Uncommit, bottom, end);
     }
   }
-
-  void start_gc(bool full, size_t gc_num) {
-    if (is_active()) {
-      if (!full) {
-        print(StartGC, gc_num);
-      } else {
-        print(StartFullGC, gc_num);
-      }
-    }
-  }
-
-  void end_gc(bool full, size_t gc_num) {
-    if (is_active()) {
-      if (!full) {
-        print(EndGC, gc_num);
-      } else {
-        print(EndFullGC, gc_num);
-      }
-    }
-  }
-
-  G1HRPrinter() : _active(false) { }
 };
 
 #endif // SHARE_VM_GC_G1_G1HRPRINTER_HPP
--- a/src/share/vm/gc/g1/g1IHOPControl.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1IHOPControl.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -24,10 +24,10 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1ErgoVerbose.hpp"
 #include "gc/g1/g1IHOPControl.hpp"
 #include "gc/g1/g1Predictions.hpp"
 #include "gc/shared/gcTrace.hpp"
+#include "logging/log.hpp"
 
 G1IHOPControl::G1IHOPControl(double initial_ihop_percent, size_t target_occupancy) :
   _initial_ihop_percent(initial_ihop_percent),
@@ -47,20 +47,14 @@
 
 void G1IHOPControl::print() {
   size_t cur_conc_mark_start_threshold = get_conc_mark_start_threshold();
-  ergo_verbose6(ErgoIHOP,
-                "basic information",
-                ergo_format_reason("value update")
-                ergo_format_byte_perc("threshold")
-                ergo_format_byte("target occupancy")
-                ergo_format_byte("current occupancy")
-                ergo_format_double("recent old gen allocation rate")
-                ergo_format_double("recent marking phase length"),
-                cur_conc_mark_start_threshold,
-                cur_conc_mark_start_threshold * 100.0 / _target_occupancy,
-                _target_occupancy,
-                G1CollectedHeap::heap()->used(),
-                _last_allocation_time_s > 0.0 ? _last_allocated_bytes / _last_allocation_time_s : 0.0,
-                last_marking_length_s());
+  log_debug(gc, ihop)("Basic information (value update), threshold: " SIZE_FORMAT "B (%1.2f), target occupancy: " SIZE_FORMAT "B, current occupancy: " SIZE_FORMAT "B,"
+                      " recent old gen allocation rate: %1.2f, recent marking phase length: %1.2f",
+                      cur_conc_mark_start_threshold,
+                      cur_conc_mark_start_threshold * 100.0 / _target_occupancy,
+                      _target_occupancy,
+                      G1CollectedHeap::heap()->used(),
+                      _last_allocation_time_s > 0.0 ? _last_allocated_bytes / _last_allocation_time_s : 0.0,
+                      last_marking_length_s());
 }
 
 void G1IHOPControl::send_trace_event(G1NewTracer* tracer) {
@@ -192,21 +186,14 @@
 void G1AdaptiveIHOPControl::print() {
   G1IHOPControl::print();
   size_t actual_target = actual_target_threshold();
-  ergo_verbose6(ErgoIHOP,
-                "adaptive IHOP information",
-                ergo_format_reason("value update")
-                ergo_format_byte_perc("threshold")
-                ergo_format_byte("internal target occupancy")
-                ergo_format_double("predicted old gen allocation rate")
-                ergo_format_double("predicted marking phase length")
-                ergo_format_str("prediction active"),
-                get_conc_mark_start_threshold(),
-                percent_of(get_conc_mark_start_threshold(), actual_target),
-                actual_target,
-                _predictor->get_new_prediction(&_allocation_rate_s),
-                _predictor->get_new_prediction(&_marking_times_s),
-                have_enough_data_for_prediction() ? "true" : "false"
-                );
+  log_debug(gc, ihop)("Adaptive IHOP information (value update), threshold: " SIZE_FORMAT "B (%1.2f), internal target occupancy: " SIZE_FORMAT "B,"
+                      " predicted old gen allocation rate: %1.2f, predicted marking phase length: %1.2f, prediction active: %s",
+                      get_conc_mark_start_threshold(),
+                      percent_of(get_conc_mark_start_threshold(), actual_target),
+                      actual_target,
+                      _predictor->get_new_prediction(&_allocation_rate_s),
+                      _predictor->get_new_prediction(&_marking_times_s),
+                      have_enough_data_for_prediction() ? "true" : "false");
 }
 
 void G1AdaptiveIHOPControl::send_trace_event(G1NewTracer* tracer) {
--- a/src/share/vm/gc/g1/g1Log.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#include "precompiled.hpp"
-#include "gc/g1/g1Log.hpp"
-#include "gc/g1/g1_globals.hpp"
-#include "runtime/globals_extension.hpp"
-
-G1Log::LogLevel G1Log::_level = G1Log::LevelNone;
-
-
-// Updates _level based on PrintGC and PrintGCDetails values (unless
-// G1LogLevel is set explicitly)
-// - PrintGC maps to "fine".
-// - PrintGCDetails maps to "finer".
-void G1Log::update_level() {
-  if (FLAG_IS_DEFAULT(G1LogLevel)) {
-    _level = LevelNone;
-    if (PrintGCDetails) {
-      _level = LevelFiner;
-    } else if (PrintGC) {
-      _level = LevelFine;
-    }
-  }
-}
-
-
-// If G1LogLevel has not been set up we will use the values of PrintGC
-// and PrintGCDetails for the logging level.
-void G1Log::init() {
-  if (!FLAG_IS_DEFAULT(G1LogLevel)) {
-    // PrintGC flags change won't have any affect, because G1LogLevel
-    // is set explicitly
-    if (G1LogLevel[0] == '\0' || strncmp("none", G1LogLevel, 4) == 0 && G1LogLevel[4] == '\0') {
-      _level = LevelNone;
-    } else if (strncmp("fine", G1LogLevel, 4) == 0 && G1LogLevel[4] == '\0') {
-      _level = LevelFine;
-    } else if (strncmp("finer", G1LogLevel, 5) == 0 && G1LogLevel[5] == '\0') {
-      _level = LevelFiner;
-    } else if (strncmp("finest", G1LogLevel, 6) == 0 && G1LogLevel[6] == '\0') {
-      _level = LevelFinest;
-    } else {
-      warning("Unknown logging level '%s', should be one of 'fine', 'finer' or 'finest'.", G1LogLevel);
-    }
-  } else {
-    update_level();
-  }
-}
-
--- a/src/share/vm/gc/g1/g1Log.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-#ifndef SHARE_VM_GC_G1_G1LOG_HPP
-#define SHARE_VM_GC_G1_G1LOG_HPP
-
-#include "memory/allocation.hpp"
-
-class G1Log : public AllStatic {
- public:
-  typedef enum {
-    LevelNone,
-    LevelFine,
-    LevelFiner,
-    LevelFinest
-  } LogLevel;
-
- private:
-  static LogLevel _level;
-
- public:
-  inline static bool fine() {
-    return _level >= LevelFine;
-  }
-
-  inline static bool finer() {
-    return _level >= LevelFiner;
-  }
-
-  inline static bool finest() {
-    return _level == LevelFinest;
-  }
-
-  static LogLevel level() {
-    return _level;
-  }
-
-  static void init();
-
-  // Update to log level to reflect runtime changes to manageable flags
-  static void update_level();
-};
-
-#endif // SHARE_VM_GC_G1_G1LOG_HPP
--- a/src/share/vm/gc/g1/g1MarkSweep.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1MarkSweep.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -29,7 +29,6 @@
 #include "classfile/vmSymbols.hpp"
 #include "code/codeCache.hpp"
 #include "code/icBuffer.hpp"
-#include "gc/g1/g1Log.hpp"
 #include "gc/g1/g1MarkSweep.hpp"
 #include "gc/g1/g1RootProcessor.hpp"
 #include "gc/g1/g1StringDedup.hpp"
@@ -38,7 +37,7 @@
 #include "gc/shared/gcLocker.hpp"
 #include "gc/shared/gcTimer.hpp"
 #include "gc/shared/gcTrace.hpp"
-#include "gc/shared/gcTraceTime.hpp"
+#include "gc/shared/gcTraceTime.inline.hpp"
 #include "gc/shared/genCollectedHeap.hpp"
 #include "gc/shared/modRefBarrierSet.hpp"
 #include "gc/shared/referencePolicy.hpp"
@@ -123,7 +122,7 @@
 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
                                     bool clear_all_softrefs) {
   // Recursively traverse all live objects and mark them
-  GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer());
+  GCTraceTime(Trace, gc) tm("Phase 1: Mark live objects", gc_timer());
 
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 
@@ -183,13 +182,8 @@
     // fail. At the end of the GC, the original mark word values
     // (including hash values) are restored to the appropriate
     // objects.
-    if (!VerifySilently) {
-      gclog_or_tty->print(" VerifyDuringGC:(full)[Verifying ");
-    }
-    g1h->verify(VerifySilently, VerifyOption_G1UseMarkWord);
-    if (!VerifySilently) {
-      gclog_or_tty->print_cr("]");
-    }
+    GCTraceTime(Info, gc, verify)("During GC (full)");
+    g1h->verify(VerifyOption_G1UseMarkWord);
   }
 
   gc_tracer()->report_object_count_after_gc(&GenMarkSweep::is_alive);
@@ -203,7 +197,7 @@
   // phase2, phase3 and phase4, but the ValidateMarkSweep live oops
   // tracking expects us to do so. See comment under phase4.
 
-  GCTraceTime tm("phase 2", G1Log::fine() && Verbose, true, gc_timer());
+  GCTraceTime(Trace, gc) tm("Phase 2: Compute new object addresses", gc_timer());
 
   prepare_compaction();
 }
@@ -236,7 +230,7 @@
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 
   // Adjust the pointers to reflect the new locations
-  GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer());
+  GCTraceTime(Trace, gc) tm("Phase 3: Adjust pointers", gc_timer());
 
   // Need cleared claim bits for the roots processing
   ClassLoaderDataGraph::clear_claimed_marks();
@@ -297,7 +291,7 @@
   // to use a higher index (saved from phase2) when verifying perm_gen.
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 
-  GCTraceTime tm("phase 4", G1Log::fine() && Verbose, true, gc_timer());
+  GCTraceTime(Trace, gc) tm("Phase 4: Move objects", gc_timer());
 
   G1SpaceCompactClosure blk;
   g1h->heap_region_iterate(&blk);
--- a/src/share/vm/gc/g1/g1RemSet.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1RemSet.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -52,7 +52,7 @@
   for (uint i = 0; i < n_workers(); i++) {
     _cset_rs_update_cl[i] = NULL;
   }
-  if (G1SummarizeRSetStats) {
+  if (log_is_enabled(Trace, gc, remset)) {
     _prev_period_summary.initialize(this);
   }
   // Initialize the card queue set used to hold cards containing
@@ -109,17 +109,6 @@
   }
 }
 
-void ScanRSClosure::printCard(HeapRegion* card_region, size_t card_index,
-    HeapWord* card_start) {
-  gclog_or_tty->print_cr("T %u Region [" PTR_FORMAT ", " PTR_FORMAT ") "
-      "RS names card " SIZE_FORMAT_HEX ": "
-      "[" PTR_FORMAT ", " PTR_FORMAT ")",
-      _worker_i,
-      p2i(card_region->bottom()), p2i(card_region->end()),
-      card_index,
-      p2i(card_start), p2i(card_start + G1BlockOffsetSharedArray::N_words));
-}
-
 void ScanRSClosure::scan_strong_code_roots(HeapRegion* r) {
   double scan_start = os::elapsedTime();
   r->strong_code_roots_do(_code_root_cl);
@@ -152,10 +141,6 @@
     }
     if (current_card < jump_to_card) continue;
     HeapWord* card_start = _g1h->bot_shared()->address_for_index(card_index);
-#if 0
-    gclog_or_tty->print("Rem set iteration yielded card [" PTR_FORMAT ", " PTR_FORMAT ").\n",
-        card_start, card_start + CardTableModRefBS::card_size_in_words);
-#endif
 
     HeapRegion* card_region = _g1h->heap_region_containing(card_start);
     _cards++;
@@ -526,31 +511,36 @@
   return has_refs_into_cset;
 }
 
-void G1RemSet::print_periodic_summary_info(const char* header) {
-  G1RemSetSummary current;
-  current.initialize(this);
+void G1RemSet::print_periodic_summary_info(const char* header, uint period_count) {
+  if ((G1SummarizeRSetStatsPeriod > 0) && log_is_enabled(Trace, gc, remset) &&
+      (period_count % G1SummarizeRSetStatsPeriod == 0)) {
 
-  _prev_period_summary.subtract_from(&current);
-  print_summary_info(&_prev_period_summary, header);
+    if (!_prev_period_summary.initialized()) {
+      _prev_period_summary.initialize(this);
+    }
 
-  _prev_period_summary.set(&current);
+    G1RemSetSummary current;
+    current.initialize(this);
+    _prev_period_summary.subtract_from(&current);
+
+    LogHandle(gc, remset) log;
+    log.trace("%s", header);
+    ResourceMark rm;
+    _prev_period_summary.print_on(log.trace_stream());
+
+    _prev_period_summary.set(&current);
+  }
 }
 
 void G1RemSet::print_summary_info() {
-  G1RemSetSummary current;
-  current.initialize(this);
-
-  print_summary_info(&current, " Cumulative RS summary");
-}
-
-void G1RemSet::print_summary_info(G1RemSetSummary * summary, const char * header) {
-  assert(summary != NULL, "just checking");
-
-  if (header != NULL) {
-    gclog_or_tty->print_cr("%s", header);
+  LogHandle(gc, remset, exit) log;
+  if (log.is_trace()) {
+    log.trace(" Cumulative RS summary");
+    G1RemSetSummary current;
+    current.initialize(this);
+    ResourceMark rm;
+    current.print_on(log.trace_stream());
   }
-
-  summary->print_on(gclog_or_tty);
 }
 
 void G1RemSet::prepare_for_verify() {
--- a/src/share/vm/gc/g1/g1RemSet.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1RemSet.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -33,6 +33,7 @@
 class G1CollectedHeap;
 class ConcurrentG1Refine;
 class G1ParPushHeapRSClosure;
+class outputStream;
 
 // A G1RemSet in which each heap region has a rem set that records the
 // external heap references into it.  Uses a mod ref bs to track updates,
@@ -63,8 +64,6 @@
   // references into the collection set.
   G1ParPushHeapRSClosure** _cset_rs_update_cl;
 
-  // Print the given summary info
-  virtual void print_summary_info(G1RemSetSummary * summary, const char * header = NULL);
 public:
   // This is called to reset dual hash tables after the gc pause
   // is finished and the initial hash table is no longer being
@@ -135,7 +134,7 @@
   virtual void print_summary_info();
 
   // Print accumulated summary info from the last time called.
-  virtual void print_periodic_summary_info(const char* header);
+  virtual void print_periodic_summary_info(const char* header, uint period_count);
 
   // Prepare remembered set for verification.
   virtual void prepare_for_verify();
--- a/src/share/vm/gc/g1/g1RemSetSummary.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1RemSetSummary.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -271,7 +271,7 @@
   void print_summary_on(outputStream* out) {
     RegionTypeCounter* counters[] = { &_young, &_humonguous, &_free, &_old, NULL };
 
-    out->print_cr("\n Current rem set statistics");
+    out->print_cr(" Current rem set statistics");
     out->print_cr("  Total per region rem sets sizes = " SIZE_FORMAT "K."
                   " Max = " SIZE_FORMAT "K.",
                   round_to_K(total_rs_mem_sz()), round_to_K(max_rs_mem_sz()));
@@ -323,7 +323,7 @@
 };
 
 void G1RemSetSummary::print_on(outputStream* out) {
-  out->print_cr("\n Recent concurrent refinement statistics");
+  out->print_cr(" Recent concurrent refinement statistics");
   out->print_cr("  Processed " SIZE_FORMAT " cards",
                 num_concurrent_refined_cards());
   out->print_cr("  Of " SIZE_FORMAT " completed buffers:", num_processed_buf_total());
--- a/src/share/vm/gc/g1/g1RemSetSummary.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1RemSetSummary.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -85,6 +85,7 @@
 
   // initialize and get the first sampling
   void initialize(G1RemSet* remset);
+  bool const initialized() { return _rs_threads_vtimes != NULL; }
 
   void print_on(outputStream* out);
 
--- a/src/share/vm/gc/g1/g1SATBCardTableModRefBS.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1SATBCardTableModRefBS.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -28,6 +28,7 @@
 #include "gc/g1/heapRegion.hpp"
 #include "gc/g1/satbMarkQueue.hpp"
 #include "gc/shared/memset_with_concurrent_readers.hpp"
+#include "logging/log.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/atomic.inline.hpp"
 #include "runtime/mutexLocker.hpp"
@@ -147,17 +148,10 @@
   assert(byte_for(low_bound) == &_byte_map[0], "Checking start of map");
   assert(byte_for(high_bound-1) <= &_byte_map[_last_valid_index], "Checking end of map");
 
-  if (TraceCardTableModRefBS) {
-    gclog_or_tty->print_cr("G1SATBCardTableModRefBS::G1SATBCardTableModRefBS: ");
-    gclog_or_tty->print_cr("  "
-                  "  &_byte_map[0]: " INTPTR_FORMAT
-                  "  &_byte_map[_last_valid_index]: " INTPTR_FORMAT,
-                  p2i(&_byte_map[0]),
-                  p2i(&_byte_map[_last_valid_index]));
-    gclog_or_tty->print_cr("  "
-                  "  byte_map_base: " INTPTR_FORMAT,
-                  p2i(byte_map_base));
-  }
+  log_trace(gc, barrier)("G1SATBCardTableModRefBS::G1SATBCardTableModRefBS: ");
+  log_trace(gc, barrier)("    &_byte_map[0]: " INTPTR_FORMAT "  &_byte_map[_last_valid_index]: " INTPTR_FORMAT,
+                         p2i(&_byte_map[0]), p2i(&_byte_map[_last_valid_index]));
+  log_trace(gc, barrier)("    byte_map_base: " INTPTR_FORMAT,  p2i(byte_map_base));
 }
 
 void
--- a/src/share/vm/gc/g1/g1StringDedupQueue.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1StringDedupQueue.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -28,6 +28,7 @@
 #include "gc/g1/g1StringDedup.hpp"
 #include "gc/g1/g1StringDedupQueue.hpp"
 #include "gc/shared/gcLocker.hpp"
+#include "logging/log.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/atomic.inline.hpp"
 #include "runtime/mutexLocker.hpp"
@@ -152,10 +153,9 @@
   }
 }
 
-void G1StringDedupQueue::print_statistics(outputStream* st) {
-  st->print_cr(
-    "   [Queue]\n"
-    "      [Dropped: " UINTX_FORMAT "]", _queue->_dropped);
+void G1StringDedupQueue::print_statistics() {
+  log_debug(gc, stringdedup)("   [Queue]");
+  log_debug(gc, stringdedup)("      [Dropped: " UINTX_FORMAT "]", _queue->_dropped);
 }
 
 void G1StringDedupQueue::verify() {
--- a/src/share/vm/gc/g1/g1StringDedupQueue.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1StringDedupQueue.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -94,7 +94,7 @@
 
   static void unlink_or_oops_do(G1StringDedupUnlinkOrOopsDoClosure* cl);
 
-  static void print_statistics(outputStream* st);
+  static void print_statistics();
   static void verify();
 };
 
--- a/src/share/vm/gc/g1/g1StringDedupStat.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1StringDedupStat.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "gc/g1/g1StringDedupStat.hpp"
+#include "logging/log.hpp"
 
 G1StringDedupStat::G1StringDedupStat() :
   _inspected(0),
@@ -68,7 +69,7 @@
   _block_elapsed       += stat._block_elapsed;
 }
 
-void G1StringDedupStat::print_summary(outputStream* st, const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {
+void G1StringDedupStat::print_summary(const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {
   double total_deduped_bytes_percent = 0.0;
 
   if (total_stat._new_bytes > 0) {
@@ -76,10 +77,8 @@
     total_deduped_bytes_percent = (double)total_stat._deduped_bytes / (double)total_stat._new_bytes * 100.0;
   }
 
-  st->date_stamp(PrintGCDateStamps);
-  st->stamp(PrintGCTimeStamps);
-  st->print_cr(
-    "[GC concurrent-string-deduplication, "
+  log_info(gc, stringdedup)(
+    "Concurrent String Deduplication "
     G1_STRDEDUP_BYTES_FORMAT_NS "->" G1_STRDEDUP_BYTES_FORMAT_NS "(" G1_STRDEDUP_BYTES_FORMAT_NS "), avg "
     G1_STRDEDUP_PERCENT_FORMAT_NS ", " G1_STRDEDUP_TIME_FORMAT "]",
     G1_STRDEDUP_BYTES_PARAM(last_stat._new_bytes),
@@ -89,7 +88,7 @@
     last_stat._exec_elapsed);
 }
 
-void G1StringDedupStat::print_statistics(outputStream* st, const G1StringDedupStat& stat, bool total) {
+void G1StringDedupStat::print_statistics(const G1StringDedupStat& stat, bool total) {
   double young_percent               = 0.0;
   double old_percent                 = 0.0;
   double skipped_percent             = 0.0;
@@ -134,29 +133,24 @@
   }
 
   if (total) {
-    st->print_cr(
+    log_debug(gc, stringdedup)(
       "   [Total Exec: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT ", Idle: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT ", Blocked: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT "]",
       stat._exec, stat._exec_elapsed, stat._idle, stat._idle_elapsed, stat._block, stat._block_elapsed);
   } else {
-    st->print_cr(
+    log_debug(gc, stringdedup)(
       "   [Last Exec: " G1_STRDEDUP_TIME_FORMAT ", Idle: " G1_STRDEDUP_TIME_FORMAT ", Blocked: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT "]",
       stat._exec_elapsed, stat._idle_elapsed, stat._block, stat._block_elapsed);
   }
-  st->print_cr(
-    "      [Inspected:    " G1_STRDEDUP_OBJECTS_FORMAT "]\n"
-    "         [Skipped:   " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]\n"
-    "         [Hashed:    " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]\n"
-    "         [Known:     " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]\n"
-    "         [New:       " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "]\n"
-    "      [Deduplicated: " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]\n"
-    "         [Young:     " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]\n"
-    "         [Old:       " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]",
-    stat._inspected,
-    stat._skipped, skipped_percent,
-    stat._hashed, hashed_percent,
-    stat._known, known_percent,
-    stat._new, new_percent, G1_STRDEDUP_BYTES_PARAM(stat._new_bytes),
-    stat._deduped, deduped_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_bytes), deduped_bytes_percent,
-    stat._deduped_young, deduped_young_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_young_bytes), deduped_young_bytes_percent,
-    stat._deduped_old, deduped_old_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_old_bytes), deduped_old_bytes_percent);
+  log_debug(gc, stringdedup)("      [Inspected:    " G1_STRDEDUP_OBJECTS_FORMAT "]", stat._inspected);
+  log_debug(gc, stringdedup)("         [Skipped:   " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]", stat._skipped, skipped_percent);
+  log_debug(gc, stringdedup)("         [Hashed:    " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]", stat._hashed, hashed_percent);
+  log_debug(gc, stringdedup)("         [Known:     " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]", stat._known, known_percent);
+  log_debug(gc, stringdedup)("         [New:       " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "]",
+                             stat._new, new_percent, G1_STRDEDUP_BYTES_PARAM(stat._new_bytes));
+  log_debug(gc, stringdedup)("      [Deduplicated: " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]",
+                             stat._deduped, deduped_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_bytes), deduped_bytes_percent);
+  log_debug(gc, stringdedup)("         [Young:     " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]",
+                             stat._deduped_young, deduped_young_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_young_bytes), deduped_young_bytes_percent);
+  log_debug(gc, stringdedup)("         [Old:       " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")]",
+                             stat._deduped_old, deduped_old_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_old_bytes), deduped_old_bytes_percent);
 }
--- a/src/share/vm/gc/g1/g1StringDedupStat.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1StringDedupStat.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -135,8 +135,8 @@
 
   void add(const G1StringDedupStat& stat);
 
-  static void print_summary(outputStream* st, const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat);
-  static void print_statistics(outputStream* st, const G1StringDedupStat& stat, bool total);
+  static void print_summary(const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat);
+  static void print_statistics(const G1StringDedupStat& stat, bool total);
 };
 
 #endif // SHARE_VM_GC_G1_G1STRINGDEDUPSTAT_HPP
--- a/src/share/vm/gc/g1/g1StringDedupTable.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1StringDedupTable.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -30,6 +30,7 @@
 #include "gc/g1/g1StringDedup.hpp"
 #include "gc/g1/g1StringDedupTable.hpp"
 #include "gc/shared/gcLocker.hpp"
+#include "logging/log.hpp"
 #include "memory/padded.inline.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/typeArrayOop.hpp"
@@ -568,19 +569,16 @@
   _entry_cache->trim(max_cache_size);
 }
 
-void G1StringDedupTable::print_statistics(outputStream* st) {
-  st->print_cr(
-    "   [Table]\n"
-    "      [Memory Usage: " G1_STRDEDUP_BYTES_FORMAT_NS "]\n"
-    "      [Size: " SIZE_FORMAT ", Min: " SIZE_FORMAT ", Max: " SIZE_FORMAT "]\n"
-    "      [Entries: " UINTX_FORMAT ", Load: " G1_STRDEDUP_PERCENT_FORMAT_NS ", Cached: " UINTX_FORMAT ", Added: " UINTX_FORMAT ", Removed: " UINTX_FORMAT "]\n"
-    "      [Resize Count: " UINTX_FORMAT ", Shrink Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS "), Grow Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS ")]\n"
-    "      [Rehash Count: " UINTX_FORMAT ", Rehash Threshold: " UINTX_FORMAT ", Hash Seed: 0x%x]\n"
-    "      [Age Threshold: " UINTX_FORMAT "]",
-    G1_STRDEDUP_BYTES_PARAM(_table->_size * sizeof(G1StringDedupEntry*) + (_table->_entries + _entry_cache->size()) * sizeof(G1StringDedupEntry)),
-    _table->_size, _min_size, _max_size,
-    _table->_entries, (double)_table->_entries / (double)_table->_size * 100.0, _entry_cache->size(), _entries_added, _entries_removed,
-    _resize_count, _table->_shrink_threshold, _shrink_load_factor * 100.0, _table->_grow_threshold, _grow_load_factor * 100.0,
-    _rehash_count, _rehash_threshold, _table->_hash_seed,
-    StringDeduplicationAgeThreshold);
+void G1StringDedupTable::print_statistics() {
+  LogHandle(gc, stringdedup) log;
+  log.debug("   [Table]");
+  log.debug("      [Memory Usage: " G1_STRDEDUP_BYTES_FORMAT_NS "]",
+            G1_STRDEDUP_BYTES_PARAM(_table->_size * sizeof(G1StringDedupEntry*) + (_table->_entries + _entry_cache->size()) * sizeof(G1StringDedupEntry)));
+  log.debug("      [Size: " SIZE_FORMAT ", Min: " SIZE_FORMAT ", Max: " SIZE_FORMAT "]", _table->_size, _min_size, _max_size);
+  log.debug("      [Entries: " UINTX_FORMAT ", Load: " G1_STRDEDUP_PERCENT_FORMAT_NS ", Cached: " UINTX_FORMAT ", Added: " UINTX_FORMAT ", Removed: " UINTX_FORMAT "]",
+            _table->_entries, (double)_table->_entries / (double)_table->_size * 100.0, _entry_cache->size(), _entries_added, _entries_removed);
+  log.debug("      [Resize Count: " UINTX_FORMAT ", Shrink Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS "), Grow Threshold: " UINTX_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT_NS ")]",
+            _resize_count, _table->_shrink_threshold, _shrink_load_factor * 100.0, _table->_grow_threshold, _grow_load_factor * 100.0);
+  log.debug("      [Rehash Count: " UINTX_FORMAT ", Rehash Threshold: " UINTX_FORMAT ", Hash Seed: 0x%x]", _rehash_count, _rehash_threshold, _table->_hash_seed);
+  log.debug("      [Age Threshold: " UINTX_FORMAT "]", StringDeduplicationAgeThreshold);
 }
--- a/src/share/vm/gc/g1/g1StringDedupTable.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1StringDedupTable.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -234,7 +234,7 @@
 
   static void unlink_or_oops_do(G1StringDedupUnlinkOrOopsDoClosure* cl, uint worker_id);
 
-  static void print_statistics(outputStream* st);
+  static void print_statistics();
   static void verify();
 };
 
--- a/src/share/vm/gc/g1/g1StringDedupThread.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1StringDedupThread.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -24,12 +24,12 @@
 
 #include "precompiled.hpp"
 #include "classfile/stringTable.hpp"
-#include "gc/g1/g1Log.hpp"
 #include "gc/g1/g1StringDedup.hpp"
 #include "gc/g1/g1StringDedupQueue.hpp"
 #include "gc/g1/g1StringDedupTable.hpp"
 #include "gc/g1/g1StringDedupThread.hpp"
 #include "gc/g1/suspendibleThreadSet.hpp"
+#include "logging/log.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/atomic.inline.hpp"
 
@@ -129,7 +129,7 @@
 
       // Print statistics
       total_stat.add(stat);
-      print(gclog_or_tty, stat, total_stat);
+      print(stat, total_stat);
     }
   }
 
@@ -152,14 +152,14 @@
   }
 }
 
-void G1StringDedupThread::print(outputStream* st, const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {
-  if (G1Log::fine() || PrintStringDeduplicationStatistics) {
-    G1StringDedupStat::print_summary(st, last_stat, total_stat);
-    if (PrintStringDeduplicationStatistics) {
-      G1StringDedupStat::print_statistics(st, last_stat, false);
-      G1StringDedupStat::print_statistics(st, total_stat, true);
-      G1StringDedupTable::print_statistics(st);
-      G1StringDedupQueue::print_statistics(st);
+void G1StringDedupThread::print(const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {
+  if (log_is_enabled(Info, gc, stringdedup)) {
+    G1StringDedupStat::print_summary(last_stat, total_stat);
+    if (log_is_enabled(Debug, gc, stringdedup)) {
+      G1StringDedupStat::print_statistics(last_stat, false);
+      G1StringDedupStat::print_statistics(total_stat, true);
+      G1StringDedupTable::print_statistics();
+      G1StringDedupQueue::print_statistics();
     }
   }
 }
--- a/src/share/vm/gc/g1/g1StringDedupThread.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1StringDedupThread.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -43,7 +43,7 @@
   G1StringDedupThread();
   ~G1StringDedupThread();
 
-  void print(outputStream* st, const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat);
+  void print(const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat);
 
 public:
   static void create();
--- a/src/share/vm/gc/g1/g1_globals.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/g1_globals.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -53,32 +53,14 @@
           "Overhead of concurrent marking")                                 \
           range(0, 100)                                                     \
                                                                             \
-  develop(intx, G1MarkingVerboseLevel, 0,                                   \
-          "Level (0-4) of verboseness of the marking code")                 \
-          range(0, 4)                                                       \
-                                                                            \
-  develop(bool, G1TraceMarkStackOverflow, false,                            \
-          "If true, extra debugging code for CM restart for ovflw.")        \
-                                                                            \
-  diagnostic(bool, G1SummarizeConcMark, false,                              \
-          "Summarize concurrent mark info")                                 \
-                                                                            \
-  diagnostic(bool, G1SummarizeRSetStats, false,                             \
-          "Summarize remembered set processing info")                       \
-                                                                            \
   diagnostic(intx, G1SummarizeRSetStatsPeriod, 0,                           \
           "The period (in number of GCs) at which we will generate "        \
           "update buffer processing info "                                  \
           "(0 means do not periodically generate this info); "              \
-          "it also requires -XX:+G1SummarizeRSetStats")                     \
+          "it also requires that logging is enabled on the trace"           \
+          "level for gc+remset")                                            \
           range(0, max_intx)                                                \
                                                                             \
-  diagnostic(bool, G1TraceConcRefinement, false,                            \
-          "Trace G1 concurrent refinement")                                 \
-                                                                            \
-  experimental(bool, G1TraceStringSymbolTableScrubbing, false,              \
-          "Trace information string and symbol table scrubbing.")           \
-                                                                            \
   product(double, G1ConcMarkStepDurationMillis, 10.0,                       \
           "Target duration of individual concurrent marking steps "         \
           "in milliseconds.")                                               \
@@ -121,10 +103,6 @@
   develop(bool, G1RSBarrierRegionFilter, true,                              \
           "If true, generate region filtering code in RS barrier")          \
                                                                             \
-  diagnostic(bool, G1PrintRegionLivenessInfo, false,                        \
-            "Prints the liveness information for all regions in the heap "  \
-            "at the end of a marking cycle.")                               \
-                                                                            \
   product(size_t, G1UpdateBufferSize, 256,                                  \
           "Size of an update buffer")                                       \
           range(1, NOT_LP64(32*M) LP64_ONLY(1*G))                           \
@@ -205,12 +183,6 @@
   develop(bool, G1ScrubRemSets, true,                                       \
           "When true, do RS scrubbing after cleanup.")                      \
                                                                             \
-  develop(bool, G1RSScrubVerbose, false,                                    \
-          "When true, do RS scrubbing with verbose output.")                \
-                                                                            \
-  develop(bool, G1YoungSurvRateVerbose, false,                              \
-          "print out the survival rate of young regions according to age.") \
-                                                                            \
   develop(intx, G1YoungSurvRateNumRegionsSummary, 0,                        \
           "the number of regions for which we'll print a surv rate "        \
           "summary.")                                                       \
@@ -222,10 +194,6 @@
           "to minimize the probability of promotion failure.")              \
           range(0, 50)                                                      \
                                                                             \
-  diagnostic(bool, G1PrintHeapRegions, false,                               \
-          "If set G1 will print information on which regions are being "    \
-          "allocated and which are reclaimed.")                             \
-                                                                            \
   develop(bool, G1HRRSUseSparseTable, true,                                 \
           "When true, use sparse table to save space.")                     \
                                                                             \
@@ -254,9 +222,6 @@
           "The number of regions we will add to the secondary free list "   \
           "at every append operation")                                      \
                                                                             \
-  develop(bool, G1ConcRegionFreeingVerbose, false,                          \
-          "Enables verboseness during concurrent region freeing")           \
-                                                                            \
   develop(bool, G1StressConcRegionFreeing, false,                           \
           "It stresses the concurrent region freeing operation")            \
                                                                             \
@@ -310,18 +275,11 @@
           "Try to reclaim dead large objects that have a few stale "        \
           "references at every young GC.")                                  \
                                                                             \
-  experimental(bool, G1TraceEagerReclaimHumongousObjects, false,            \
-          "Print some information about large object liveness "             \
-          "at every young GC.")                                             \
-                                                                            \
   experimental(uintx, G1OldCSetRegionThresholdPercent, 10,                  \
           "An upper bound for the number of old CSet regions expressed "    \
           "as a percentage of the heap size.")                              \
           range(0, 100)                                                     \
                                                                             \
-  experimental(ccstr, G1LogLevel, NULL,                                     \
-          "Log level for G1 logging: fine, finer, finest")                  \
-                                                                            \
   notproduct(bool, G1EvacuationFailureALot, false,                          \
           "Force use of evacuation failure handling during certain "        \
           "evacuation pauses")                                              \
--- a/src/share/vm/gc/g1/heapRegion.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/heapRegion.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -34,6 +34,7 @@
 #include "gc/shared/genOopClosures.inline.hpp"
 #include "gc/shared/liveRange.hpp"
 #include "gc/shared/space.inline.hpp"
+#include "logging/log.hpp"
 #include "memory/iterator.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/atomic.inline.hpp"
@@ -479,10 +480,8 @@
         // Object is in the region. Check that its less than top
         if (_hr->top() <= (HeapWord*)obj) {
           // Object is above top
-          gclog_or_tty->print_cr("Object " PTR_FORMAT " in region "
-                                 "[" PTR_FORMAT ", " PTR_FORMAT ") is above "
-                                 "top " PTR_FORMAT,
-                                 p2i(obj), p2i(_hr->bottom()), p2i(_hr->end()), p2i(_hr->top()));
+          log_info(gc, verify)("Object " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ") is above top " PTR_FORMAT,
+                               p2i(obj), p2i(_hr->bottom()), p2i(_hr->end()), p2i(_hr->top()));
           _failures = true;
           return;
         }
@@ -515,23 +514,19 @@
     if (nm != NULL) {
       // Verify that the nemthod is live
       if (!nm->is_alive()) {
-        gclog_or_tty->print_cr("region [" PTR_FORMAT "," PTR_FORMAT "] has dead nmethod "
-                               PTR_FORMAT " in its strong code roots",
-                               p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
+        log_info(gc, verify)("region [" PTR_FORMAT "," PTR_FORMAT "] has dead nmethod " PTR_FORMAT " in its strong code roots",
+                             p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
         _failures = true;
       } else {
         VerifyStrongCodeRootOopClosure oop_cl(_hr, nm);
         nm->oops_do(&oop_cl);
         if (!oop_cl.has_oops_in_region()) {
-          gclog_or_tty->print_cr("region [" PTR_FORMAT "," PTR_FORMAT "] has nmethod "
-                                 PTR_FORMAT " in its strong code roots "
-                                 "with no pointers into region",
-                                 p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
+          log_info(gc, verify)("region [" PTR_FORMAT "," PTR_FORMAT "] has nmethod " PTR_FORMAT " in its strong code roots with no pointers into region",
+                               p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
           _failures = true;
         } else if (oop_cl.failures()) {
-          gclog_or_tty->print_cr("region [" PTR_FORMAT "," PTR_FORMAT "] has other "
-                                 "failures for nmethod " PTR_FORMAT,
-                                 p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
+          log_info(gc, verify)("region [" PTR_FORMAT "," PTR_FORMAT "] has other failures for nmethod " PTR_FORMAT,
+                               p2i(_hr->bottom()), p2i(_hr->end()), p2i(nm));
           _failures = true;
         }
       }
@@ -564,9 +559,8 @@
   // on its strong code root list
   if (is_empty()) {
     if (strong_code_roots_length > 0) {
-      gclog_or_tty->print_cr("region [" PTR_FORMAT "," PTR_FORMAT "] is empty "
-                             "but has " SIZE_FORMAT " code root entries",
-                             p2i(bottom()), p2i(end()), strong_code_roots_length);
+      log_info(gc, verify)("region [" PTR_FORMAT "," PTR_FORMAT "] is empty but has " SIZE_FORMAT " code root entries",
+                           p2i(bottom()), p2i(end()), strong_code_roots_length);
       *failures = true;
     }
     return;
@@ -574,9 +568,8 @@
 
   if (is_continues_humongous()) {
     if (strong_code_roots_length > 0) {
-      gclog_or_tty->print_cr("region " HR_FORMAT " is a continuation of a humongous "
-                             "region but has " SIZE_FORMAT " code root entries",
-                             HR_FORMAT_PARAMS(this), strong_code_roots_length);
+      log_info(gc, verify)("region " HR_FORMAT " is a continuation of a humongous region but has " SIZE_FORMAT " code root entries",
+                           HR_FORMAT_PARAMS(this), strong_code_roots_length);
       *failures = true;
     }
     return;
@@ -590,7 +583,7 @@
   }
 }
 
-void HeapRegion::print() const { print_on(gclog_or_tty); }
+void HeapRegion::print() const { print_on(tty); }
 void HeapRegion::print_on(outputStream* st) const {
   st->print("|%4u", this->_hrm_index);
   st->print("|" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT,
@@ -651,6 +644,7 @@
     assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),
            "Precondition");
     T heap_oop = oopDesc::load_heap_oop(p);
+    LogHandle(gc, verify) log;
     if (!oopDesc::is_null(heap_oop)) {
       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
       bool failed = false;
@@ -659,35 +653,26 @@
                         Mutex::_no_safepoint_check_flag);
 
         if (!_failures) {
-          gclog_or_tty->cr();
-          gclog_or_tty->print_cr("----------");
+          log.info("----------");
         }
+        ResourceMark rm;
         if (!_g1h->is_in_closed_subset(obj)) {
           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
-          gclog_or_tty->print_cr("Field " PTR_FORMAT
-                                 " of live obj " PTR_FORMAT " in region "
-                                 "[" PTR_FORMAT ", " PTR_FORMAT ")",
-                                 p2i(p), p2i(_containing_obj),
-                                 p2i(from->bottom()), p2i(from->end()));
-          print_object(gclog_or_tty, _containing_obj);
-          gclog_or_tty->print_cr("points to obj " PTR_FORMAT " not in the heap",
-                                 p2i(obj));
+          log.info("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
+                   p2i(p), p2i(_containing_obj), p2i(from->bottom()), p2i(from->end()));
+          print_object(log.info_stream(), _containing_obj);
+          log.info("points to obj " PTR_FORMAT " not in the heap", p2i(obj));
         } else {
           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
           HeapRegion* to   = _g1h->heap_region_containing((HeapWord*)obj);
-          gclog_or_tty->print_cr("Field " PTR_FORMAT
-                                 " of live obj " PTR_FORMAT " in region "
-                                 "[" PTR_FORMAT ", " PTR_FORMAT ")",
-                                 p2i(p), p2i(_containing_obj),
-                                 p2i(from->bottom()), p2i(from->end()));
-          print_object(gclog_or_tty, _containing_obj);
-          gclog_or_tty->print_cr("points to dead obj " PTR_FORMAT " in region "
-                                 "[" PTR_FORMAT ", " PTR_FORMAT ")",
-                                 p2i(obj), p2i(to->bottom()), p2i(to->end()));
-          print_object(gclog_or_tty, obj);
+          log.info("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
+                   p2i(p), p2i(_containing_obj), p2i(from->bottom()), p2i(from->end()));
+          print_object(log.info_stream(), _containing_obj);
+          log.info("points to dead obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
+                   p2i(obj), p2i(to->bottom()), p2i(to->end()));
+          print_object(log.info_stream(), obj);
         }
-        gclog_or_tty->print_cr("----------");
-        gclog_or_tty->flush();
+        log.info("----------");
         _failures = true;
         failed = true;
         _n_failures++;
@@ -714,25 +699,17 @@
                             Mutex::_no_safepoint_check_flag);
 
             if (!_failures) {
-              gclog_or_tty->cr();
-              gclog_or_tty->print_cr("----------");
+              log.info("----------");
             }
-            gclog_or_tty->print_cr("Missing rem set entry:");
-            gclog_or_tty->print_cr("Field " PTR_FORMAT " "
-                                   "of obj " PTR_FORMAT ", "
-                                   "in region " HR_FORMAT,
-                                   p2i(p), p2i(_containing_obj),
-                                   HR_FORMAT_PARAMS(from));
-            _containing_obj->print_on(gclog_or_tty);
-            gclog_or_tty->print_cr("points to obj " PTR_FORMAT " "
-                                   "in region " HR_FORMAT,
-                                   p2i(obj),
-                                   HR_FORMAT_PARAMS(to));
-            obj->print_on(gclog_or_tty);
-            gclog_or_tty->print_cr("Obj head CTE = %d, field CTE = %d.",
-                          cv_obj, cv_field);
-            gclog_or_tty->print_cr("----------");
-            gclog_or_tty->flush();
+            log.info("Missing rem set entry:");
+            log.info("Field " PTR_FORMAT " of obj " PTR_FORMAT ", in region " HR_FORMAT,
+                     p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
+            ResourceMark rm;
+            _containing_obj->print_on(log.info_stream());
+            log.info("points to obj " PTR_FORMAT " in region " HR_FORMAT, p2i(obj), HR_FORMAT_PARAMS(to));
+            obj->print_on(log.info_stream());
+            log.info("Obj head CTE = %d, field CTE = %d.", cv_obj, cv_field);
+            log.info("----------");
             _failures = true;
             if (!failed) _n_failures++;
           }
@@ -766,13 +743,13 @@
                                    (vo == VerifyOption_G1UsePrevMarking &&
                                    ClassLoaderDataGraph::unload_list_contains(klass));
         if (!is_metaspace_object) {
-          gclog_or_tty->print_cr("klass " PTR_FORMAT " of object " PTR_FORMAT " "
-                                 "not metadata", p2i(klass), p2i(obj));
+          log_info(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
+                               "not metadata", p2i(klass), p2i(obj));
           *failures = true;
           return;
         } else if (!klass->is_klass()) {
-          gclog_or_tty->print_cr("klass " PTR_FORMAT " of object " PTR_FORMAT " "
-                                 "not a klass", p2i(klass), p2i(obj));
+          log_info(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
+                               "not a klass", p2i(klass), p2i(obj));
           *failures = true;
           return;
         } else {
@@ -787,7 +764,7 @@
           }
         }
       } else {
-        gclog_or_tty->print_cr(PTR_FORMAT " no an oop", p2i(obj));
+        log_info(gc, verify)(PTR_FORMAT " no an oop", p2i(obj));
         *failures = true;
         return;
       }
@@ -803,13 +780,13 @@
   if (is_region_humongous) {
     oop obj = oop(this->humongous_start_region()->bottom());
     if ((HeapWord*)obj > bottom() || (HeapWord*)obj + obj->size() < bottom()) {
-      gclog_or_tty->print_cr("this humongous region is not part of its' humongous object " PTR_FORMAT, p2i(obj));
+      log_info(gc, verify)("this humongous region is not part of its' humongous object " PTR_FORMAT, p2i(obj));
     }
   }
 
   if (!is_region_humongous && p != top()) {
-    gclog_or_tty->print_cr("end of last object " PTR_FORMAT " "
-                           "does not match top " PTR_FORMAT, p2i(p), p2i(top()));
+    log_info(gc, verify)("end of last object " PTR_FORMAT " "
+                         "does not match top " PTR_FORMAT, p2i(p), p2i(top()));
     *failures = true;
     return;
   }
@@ -823,9 +800,9 @@
     HeapWord* addr_1 = p;
     HeapWord* b_start_1 = _offsets.block_start_const(addr_1);
     if (b_start_1 != p) {
-      gclog_or_tty->print_cr("BOT look up for top: " PTR_FORMAT " "
-                             " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
-                             p2i(addr_1), p2i(b_start_1), p2i(p));
+      log_info(gc, verify)("BOT look up for top: " PTR_FORMAT " "
+                           " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
+                           p2i(addr_1), p2i(b_start_1), p2i(p));
       *failures = true;
       return;
     }
@@ -835,9 +812,9 @@
     if (addr_2 < the_end) {
       HeapWord* b_start_2 = _offsets.block_start_const(addr_2);
       if (b_start_2 != p) {
-        gclog_or_tty->print_cr("BOT look up for top + 1: " PTR_FORMAT " "
-                               " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
-                               p2i(addr_2), p2i(b_start_2), p2i(p));
+        log_info(gc, verify)("BOT look up for top + 1: " PTR_FORMAT " "
+                             " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
+                             p2i(addr_2), p2i(b_start_2), p2i(p));
         *failures = true;
         return;
       }
@@ -849,9 +826,9 @@
     if (addr_3 < the_end) {
       HeapWord* b_start_3 = _offsets.block_start_const(addr_3);
       if (b_start_3 != p) {
-        gclog_or_tty->print_cr("BOT look up for top + diff: " PTR_FORMAT " "
-                               " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
-                               p2i(addr_3), p2i(b_start_3), p2i(p));
+        log_info(gc, verify)("BOT look up for top + diff: " PTR_FORMAT " "
+                             " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
+                             p2i(addr_3), p2i(b_start_3), p2i(p));
         *failures = true;
         return;
       }
@@ -861,9 +838,9 @@
     HeapWord* addr_4 = the_end - 1;
     HeapWord* b_start_4 = _offsets.block_start_const(addr_4);
     if (b_start_4 != p) {
-      gclog_or_tty->print_cr("BOT look up for end - 1: " PTR_FORMAT " "
-                             " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
-                             p2i(addr_4), p2i(b_start_4), p2i(p));
+      log_info(gc, verify)("BOT look up for end - 1: " PTR_FORMAT " "
+                           " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
+                           p2i(addr_4), p2i(b_start_4), p2i(p));
       *failures = true;
       return;
     }
@@ -914,7 +891,7 @@
 
 void G1OffsetTableContigSpace::print() const {
   print_short();
-  gclog_or_tty->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", "
+  tty->print_cr(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", "
                 INTPTR_FORMAT ", " INTPTR_FORMAT ")",
                 p2i(bottom()), p2i(top()), p2i(_offsets.threshold()), p2i(end()));
 }
--- a/src/share/vm/gc/g1/heapRegionRemSet.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/heapRegionRemSet.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -560,20 +560,13 @@
 void OtherRegionsTable::scrub(CardTableModRefBS* ctbs,
                               BitMap* region_bm, BitMap* card_bm) {
   // First eliminated garbage regions from the coarse map.
-  if (G1RSScrubVerbose) {
-    gclog_or_tty->print_cr("Scrubbing region %u:", _hr->hrm_index());
-  }
+  log_develop_trace(gc, remset, scrub)("Scrubbing region %u:", _hr->hrm_index());
 
   assert(_coarse_map.size() == region_bm->size(), "Precondition");
-  if (G1RSScrubVerbose) {
-    gclog_or_tty->print("   Coarse map: before = " SIZE_FORMAT "...",
-                        _n_coarse_entries);
-  }
+  log_develop_trace(gc, remset, scrub)("   Coarse map: before = " SIZE_FORMAT "...", _n_coarse_entries);
   _coarse_map.set_intersection(*region_bm);
   _n_coarse_entries = _coarse_map.count_one_bits();
-  if (G1RSScrubVerbose) {
-    gclog_or_tty->print_cr("   after = " SIZE_FORMAT ".", _n_coarse_entries);
-  }
+  log_develop_trace(gc, remset, scrub)("   after = " SIZE_FORMAT ".", _n_coarse_entries);
 
   // Now do the fine-grained maps.
   for (size_t i = 0; i < _max_fine_entries; i++) {
@@ -582,28 +575,19 @@
     while (cur != NULL) {
       PerRegionTable* nxt = cur->collision_list_next();
       // If the entire region is dead, eliminate.
-      if (G1RSScrubVerbose) {
-        gclog_or_tty->print_cr("     For other region %u:",
-                               cur->hr()->hrm_index());
-      }
+      log_develop_trace(gc, remset, scrub)("     For other region %u:", cur->hr()->hrm_index());
       if (!region_bm->at((size_t) cur->hr()->hrm_index())) {
         *prev = nxt;
         cur->set_collision_list_next(NULL);
         _n_fine_entries--;
-        if (G1RSScrubVerbose) {
-          gclog_or_tty->print_cr("          deleted via region map.");
-        }
+        log_develop_trace(gc, remset, scrub)("          deleted via region map.");
         unlink_from_all(cur);
         PerRegionTable::free(cur);
       } else {
         // Do fine-grain elimination.
-        if (G1RSScrubVerbose) {
-          gclog_or_tty->print("          occ: before = %4d.", cur->occupied());
-        }
+        log_develop_trace(gc, remset, scrub)("          occ: before = %4d.", cur->occupied());
         cur->scrub(ctbs, card_bm);
-        if (G1RSScrubVerbose) {
-          gclog_or_tty->print_cr("          after = %4d.", cur->occupied());
-        }
+        log_develop_trace(gc, remset, scrub)("          after = %4d.", cur->occupied());
         // Did that empty the table completely?
         if (cur->occupied() == 0) {
           *prev = nxt;
@@ -799,15 +783,15 @@
   while (iter.has_next(card_index)) {
     HeapWord* card_start =
       G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index);
-    gclog_or_tty->print_cr("  Card " PTR_FORMAT, p2i(card_start));
+    tty->print_cr("  Card " PTR_FORMAT, p2i(card_start));
   }
   if (iter.n_yielded() != occupied()) {
-    gclog_or_tty->print_cr("Yielded disagrees with occupied:");
-    gclog_or_tty->print_cr("  " SIZE_FORMAT_W(6) " yielded (" SIZE_FORMAT_W(6)
+    tty->print_cr("Yielded disagrees with occupied:");
+    tty->print_cr("  " SIZE_FORMAT_W(6) " yielded (" SIZE_FORMAT_W(6)
                   " coarse, " SIZE_FORMAT_W(6) " fine).",
                   iter.n_yielded(),
                   iter.n_yielded_coarse(), iter.n_yielded_fine());
-    gclog_or_tty->print_cr("  " SIZE_FORMAT_W(6) " occ     (" SIZE_FORMAT_W(6)
+    tty->print_cr("  " SIZE_FORMAT_W(6) " occ     (" SIZE_FORMAT_W(6)
                            " coarse, " SIZE_FORMAT_W(6) " fine).",
                   occupied(), occ_coarse(), occ_fine());
   }
@@ -1071,7 +1055,7 @@
   while (iter.has_next(card_index)) {
     HeapWord* card_start =
       G1CollectedHeap::heap()->bot_shared()->address_for_index(card_index);
-    gclog_or_tty->print_cr("  Card " PTR_FORMAT ".", p2i(card_start));
+    tty->print_cr("  Card " PTR_FORMAT ".", p2i(card_start));
     sum++;
   }
   guarantee(sum == 11 - 3 + 2048, "Failure");
--- a/src/share/vm/gc/g1/heapRegionRemSet.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/heapRegionRemSet.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -86,7 +86,7 @@
 
   static void invalidate(uint start_idx, size_t num_regions);
 
-  static void print(outputStream* out = gclog_or_tty) PRODUCT_RETURN;
+  static void print(outputStream* out = tty) PRODUCT_RETURN;
 
   static size_t static_mem_size() {
     return _static_mem_size;
--- a/src/share/vm/gc/g1/heapRegionSet.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/heapRegionSet.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -261,24 +261,6 @@
   _last = NULL;
 }
 
-void FreeRegionList::print_on(outputStream* out, bool print_contents) {
-  HeapRegionSetBase::print_on(out, print_contents);
-  out->print_cr("  Linking");
-  out->print_cr("    head              : " PTR_FORMAT, p2i(_head));
-  out->print_cr("    tail              : " PTR_FORMAT, p2i(_tail));
-
-  if (print_contents) {
-    out->print_cr("  Contents");
-    FreeRegionListIterator iter(this);
-    while (iter.more_available()) {
-      HeapRegion* hr = iter.get_next();
-      hr->print_on(out);
-    }
-  }
-
-  out->cr();
-}
-
 void FreeRegionList::verify_list() {
   HeapRegion* curr = _head;
   HeapRegion* prev1 = NULL;
--- a/src/share/vm/gc/g1/heapRegionSet.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/heapRegionSet.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -250,8 +250,6 @@
   void remove_starting_at(HeapRegion* first, uint num_regions);
 
   virtual void verify();
-
-  virtual void print_on(outputStream* out, bool print_contents = false);
 };
 
 // Iterator class that provides a convenient way to iterate over the
--- a/src/share/vm/gc/g1/satbMarkQueue.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/satbMarkQueue.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -199,9 +199,8 @@
 
 void SATBMarkQueue::print(const char* name,
                           void** buf, size_t index, size_t sz) {
-  gclog_or_tty->print_cr("  SATB BUFFER [%s] buf: " PTR_FORMAT " "
-                         "index: " SIZE_FORMAT " sz: " SIZE_FORMAT,
-                         name, p2i(buf), index, sz);
+  tty->print_cr("  SATB BUFFER [%s] buf: " PTR_FORMAT " index: " SIZE_FORMAT " sz: " SIZE_FORMAT,
+                name, p2i(buf), index, sz);
 }
 #endif // PRODUCT
 
@@ -222,16 +221,13 @@
 
 #ifdef ASSERT
 void SATBMarkQueueSet::dump_active_states(bool expected_active) {
-  gclog_or_tty->print_cr("Expected SATB active state: %s",
-                         expected_active ? "ACTIVE" : "INACTIVE");
-  gclog_or_tty->print_cr("Actual SATB active states:");
-  gclog_or_tty->print_cr("  Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");
+  log_info(gc, verify)("Expected SATB active state: %s", expected_active ? "ACTIVE" : "INACTIVE");
+  log_info(gc, verify)("Actual SATB active states:");
+  log_info(gc, verify)("  Queue set: %s", is_active() ? "ACTIVE" : "INACTIVE");
   for (JavaThread* t = Threads::first(); t; t = t->next()) {
-    gclog_or_tty->print_cr("  Thread \"%s\" queue: %s", t->name(),
-                           t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE");
+    log_info(gc, verify)("  Thread \"%s\" queue: %s", t->name(), t->satb_mark_queue().is_active() ? "ACTIVE" : "INACTIVE");
   }
-  gclog_or_tty->print_cr("  Shared queue: %s",
-                         shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");
+  log_info(gc, verify)("  Shared queue: %s", shared_satb_queue()->is_active() ? "ACTIVE" : "INACTIVE");
 }
 
 void SATBMarkQueueSet::verify_active_states(bool expected_active) {
@@ -318,8 +314,8 @@
   char buffer[SATB_PRINTER_BUFFER_SIZE];
   assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
 
-  gclog_or_tty->cr();
-  gclog_or_tty->print_cr("SATB BUFFERS [%s]", msg);
+  tty->cr();
+  tty->print_cr("SATB BUFFERS [%s]", msg);
 
   BufferNode* nd = _completed_buffers_head;
   int i = 0;
@@ -338,7 +334,7 @@
 
   shared_satb_queue()->print("Shared");
 
-  gclog_or_tty->cr();
+  tty->cr();
 }
 #endif // PRODUCT
 
--- a/src/share/vm/gc/g1/survRateGroup.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/survRateGroup.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -27,6 +27,7 @@
 #include "gc/g1/g1Predictions.hpp"
 #include "gc/g1/heapRegion.hpp"
 #include "gc/g1/survRateGroup.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.hpp"
 
 SurvRateGroup::SurvRateGroup(G1Predictions* predictor,
@@ -163,12 +164,11 @@
 
 #ifndef PRODUCT
 void SurvRateGroup::print() {
-  gclog_or_tty->print_cr("Surv Rate Group: %s (" SIZE_FORMAT " entries)",
-                _name, _region_num);
+  log_develop_trace(gc, survivor)("Surv Rate Group: %s (" SIZE_FORMAT " entries)", _name, _region_num);
   for (size_t i = 0; i < _region_num; ++i) {
-    gclog_or_tty->print_cr("    age " SIZE_FORMAT_W(4) "   surv rate %6.2lf %%   pred %6.2lf %%",
-                           i, _surv_rate[i] * 100.0,
-                           _predictor->get_new_prediction(_surv_rate_pred[i]) * 100.0);
+    log_develop_trace(gc, survivor)("    age " SIZE_FORMAT_W(4) "   surv rate %6.2lf %%   pred %6.2lf %%",
+                                    i, _surv_rate[i] * 100.0,
+                                    _predictor->get_new_prediction(_surv_rate_pred[i]) * 100.0);
   }
 }
 
@@ -178,22 +178,20 @@
   if (length == 0)
     return;
 
-  gclog_or_tty->cr();
-  gclog_or_tty->print_cr("%s Rate Summary (for up to age " SIZE_FORMAT ")", _name, length-1);
-  gclog_or_tty->print_cr("      age range     survival rate (avg)      samples (avg)");
-  gclog_or_tty->print_cr("  ---------------------------------------------------------");
+  log_trace(gc, survivor)("%s Rate Summary (for up to age " SIZE_FORMAT ")", _name, length-1);
+  log_trace(gc, survivor)("      age range     survival rate (avg)      samples (avg)");
+  log_trace(gc, survivor)("  ---------------------------------------------------------");
 
   size_t index = 0;
   size_t limit = MIN2((int) length, 10);
   while (index < limit) {
-    gclog_or_tty->print_cr("           " SIZE_FORMAT_W(4)
-                           "                 %6.2lf%%             %6.2lf",
-                           index, _summary_surv_rates[index]->avg() * 100.0,
-                           (double) _summary_surv_rates[index]->num());
+    log_trace(gc, survivor)("           " SIZE_FORMAT_W(4) "                 %6.2lf%%             %6.2lf",
+                            index, _summary_surv_rates[index]->avg() * 100.0,
+                            (double) _summary_surv_rates[index]->num());
     ++index;
   }
 
-  gclog_or_tty->print_cr("  ---------------------------------------------------------");
+  log_trace(gc, survivor)("  ---------------------------------------------------------");
 
   int num = 0;
   double sum = 0.0;
@@ -205,16 +203,15 @@
     ++index;
 
     if (index == length || num % 10 == 0) {
-      gclog_or_tty->print_cr("   " SIZE_FORMAT_W(4) " .. " SIZE_FORMAT_W(4)
-                             "                 %6.2lf%%             %6.2lf",
-                             (index-1) / 10 * 10, index-1, sum / (double) num,
-                             (double) samples / (double) num);
+      log_trace(gc, survivor)("   " SIZE_FORMAT_W(4) " .. " SIZE_FORMAT_W(4) "                 %6.2lf%%             %6.2lf",
+                              (index-1) / 10 * 10, index-1, sum / (double) num,
+                              (double) samples / (double) num);
       sum = 0.0;
       num = 0;
       samples = 0;
     }
   }
 
-  gclog_or_tty->print_cr("  ---------------------------------------------------------");
+  log_trace(gc, survivor)("  ---------------------------------------------------------");
 }
 #endif // PRODUCT
--- a/src/share/vm/gc/g1/vm_operations_g1.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/vm_operations_g1.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -27,10 +27,9 @@
 #include "gc/g1/g1CollectedHeap.inline.hpp"
 #include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/shared/gcId.hpp"
-#include "gc/g1/g1Log.hpp"
 #include "gc/g1/vm_operations_g1.hpp"
 #include "gc/shared/gcTimer.hpp"
-#include "gc/shared/gcTraceTime.hpp"
+#include "gc/shared/gcTraceTime.inline.hpp"
 #include "gc/shared/isGCActiveMark.hpp"
 #include "runtime/interfaceSupport.hpp"
 
@@ -226,10 +225,10 @@
 }
 
 void VM_CGC_Operation::doit() {
-  TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
+  GCIdMark gc_id_mark(_gc_id);
+  GCTraceCPUTime tcpu;
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
-  GCIdMark gc_id_mark(_gc_id);
-  GCTraceTime t(_printGCMessage, G1Log::fine(), true, g1h->gc_timer_cm());
+  GCTraceTime(Info, gc) t(_printGCMessage, g1h->gc_timer_cm(), GCCause::_no_gc, true);
   IsGCActiveMark x;
   _cl->do_void();
 }
--- a/src/share/vm/gc/g1/workerDataArray.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/workerDataArray.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -30,13 +30,11 @@
   const uint length = 3;
   const char* title = "Test array";
   const bool print_sum = false;
-  const int log_level = 3;
   const uint indent_level = 2;
 
-  WorkerDataArray<size_t> array(length, title, print_sum, log_level, indent_level);
+  WorkerDataArray<size_t> array(length, title, print_sum, indent_level);
   assert(strncmp(array.title(), title, strlen(title)) == 0 , "Expected titles to match");
   assert(array.should_print_sum() == print_sum, "Expected should_print_sum to match print_sum");
-  assert(array.log_level() == log_level, "Expected log levels to match");
   assert(array.indentation() == indent_level, "Expected indentation to match");
 
   const size_t expected[length] = {5, 3, 7};
--- a/src/share/vm/gc/g1/workerDataArray.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/workerDataArray.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -32,7 +32,6 @@
   uint        _length;
   const char* _title;
   bool        _print_sum;
-  int         _log_level;
   uint        _indent_level;
   bool        _enabled;
 
@@ -46,7 +45,6 @@
   WorkerDataArray(uint length,
                   const char* title,
                   bool print_sum,
-                  int log_level,
                   uint indent_level);
 
   ~WorkerDataArray();
@@ -80,10 +78,6 @@
     return _print_sum;
   }
 
-  int log_level() const {
-    return _log_level;
-  }
-
   void clear();
   void set_enabled(bool enabled) {
     _enabled = enabled;
--- a/src/share/vm/gc/g1/workerDataArray.inline.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/workerDataArray.inline.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -29,12 +29,10 @@
 WorkerDataArray<T>::WorkerDataArray(uint length,
                                     const char* title,
                                     bool print_sum,
-                                    int log_level,
                                     uint indent_level) :
  _title(title),
  _length(0),
  _print_sum(print_sum),
- _log_level(log_level),
  _indent_level(indent_level),
  _thread_work_items(NULL),
  _enabled(true) {
--- a/src/share/vm/gc/g1/youngList.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/g1/youngList.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -29,6 +29,7 @@
 #include "gc/g1/heapRegion.inline.hpp"
 #include "gc/g1/heapRegionRemSet.hpp"
 #include "gc/g1/youngList.hpp"
+#include "logging/log.hpp"
 #include "utilities/ostream.hpp"
 
 YoungList::YoungList(G1CollectedHeap* g1h) :
@@ -98,10 +99,10 @@
   HeapRegion* last = NULL;
   while (curr != NULL) {
     if (!curr->is_young()) {
-      gclog_or_tty->print_cr("### YOUNG REGION " PTR_FORMAT "-" PTR_FORMAT " "
-                             "incorrectly tagged (y: %d, surv: %d)",
-                             p2i(curr->bottom()), p2i(curr->end()),
-                             curr->is_young(), curr->is_survivor());
+      log_info(gc, verify)("### YOUNG REGION " PTR_FORMAT "-" PTR_FORMAT " "
+                           "incorrectly tagged (y: %d, surv: %d)",
+                           p2i(curr->bottom()), p2i(curr->end()),
+                           curr->is_young(), curr->is_survivor());
       ret = false;
     }
     ++length;
@@ -111,9 +112,8 @@
   ret = ret && (length == _length);
 
   if (!ret) {
-    gclog_or_tty->print_cr("### YOUNG LIST seems not well formed!");
-    gclog_or_tty->print_cr("###   list has %u entries, _length is %u",
-                           length, _length);
+    log_info(gc, verify)("### YOUNG LIST seems not well formed!");
+    log_info(gc, verify)("###   list has %u entries, _length is %u", length, _length);
   }
 
   return ret;
@@ -123,20 +123,19 @@
   bool ret = true;
 
   if (_length != 0) {
-    gclog_or_tty->print_cr("### YOUNG LIST should have 0 length, not %u",
-                  _length);
+    log_info(gc, verify)("### YOUNG LIST should have 0 length, not %u", _length);
     ret = false;
   }
   if (check_sample && _last_sampled_rs_lengths != 0) {
-    gclog_or_tty->print_cr("### YOUNG LIST has non-zero last sampled RS lengths");
+    log_info(gc, verify)("### YOUNG LIST has non-zero last sampled RS lengths");
     ret = false;
   }
   if (_head != NULL) {
-    gclog_or_tty->print_cr("### YOUNG LIST does not have a NULL head");
+    log_info(gc, verify)("### YOUNG LIST does not have a NULL head");
     ret = false;
   }
   if (!ret) {
-    gclog_or_tty->print_cr("### YOUNG LIST does not seem empty");
+    log_info(gc, verify)("### YOUNG LIST does not seem empty");
   }
 
   return ret;
@@ -171,7 +170,6 @@
   _curr = _curr->get_next_young_region();
   if (_curr == NULL) {
     _last_sampled_rs_lengths = _sampled_rs_lengths;
-    // gclog_or_tty->print_cr("last sampled RS lengths = %d", _last_sampled_rs_lengths);
   }
 }
 
@@ -222,13 +220,13 @@
   const char* names[] = {"YOUNG", "SURVIVOR"};
 
   for (uint list = 0; list < ARRAY_SIZE(lists); ++list) {
-    gclog_or_tty->print_cr("%s LIST CONTENTS", names[list]);
+    tty->print_cr("%s LIST CONTENTS", names[list]);
     HeapRegion *curr = lists[list];
     if (curr == NULL) {
-      gclog_or_tty->print_cr("  empty");
+      tty->print_cr("  empty");
     }
     while (curr != NULL) {
-      gclog_or_tty->print_cr("  " HR_FORMAT ", P: " PTR_FORMAT ", N: " PTR_FORMAT ", age: %4d",
+      tty->print_cr("  " HR_FORMAT ", P: " PTR_FORMAT ", N: " PTR_FORMAT ", age: %4d",
                              HR_FORMAT_PARAMS(curr),
                              p2i(curr->prev_top_at_mark_start()),
                              p2i(curr->next_top_at_mark_start()),
@@ -237,5 +235,5 @@
     }
   }
 
-  gclog_or_tty->cr();
+  tty->cr();
 }
--- a/src/share/vm/gc/parallel/adjoiningGenerations.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/adjoiningGenerations.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -27,6 +27,9 @@
 #include "gc/parallel/adjoiningVirtualSpaces.hpp"
 #include "gc/parallel/generationSizer.hpp"
 #include "gc/parallel/parallelScavengeHeap.hpp"
+#include "logging/log.hpp"
+#include "memory/resourceArea.hpp"
+#include "utilities/ostream.hpp"
 
 // If boundary moving is being used, create the young gen and old
 // gen with ASPSYoungGen and ASPSOldGen, respectively.  Revert to
@@ -116,6 +119,29 @@
   return virtual_spaces()->reserved_space().size();
 }
 
+void log_before_expansion(bool old, size_t expand_in_bytes, size_t change_in_bytes, size_t max_size) {
+  LogHandle(heap, ergo) log;
+  if (!log.is_debug()) {
+   return;
+  }
+  log.debug("Before expansion of %s gen with boundary move", old ? "old" : "young");
+  log.debug("  Requested change: " SIZE_FORMAT_HEX "  Attempted change: " SIZE_FORMAT_HEX,
+                        expand_in_bytes, change_in_bytes);
+  ResourceMark rm;
+  ParallelScavengeHeap::heap()->print_on(log.debug_stream());
+  log.debug("  PS%sGen max size: " SIZE_FORMAT "K", old ? "Old" : "Young", max_size/K);
+}
+
+void log_after_expansion(bool old, size_t max_size) {
+  LogHandle(heap, ergo) log;
+  if (!log.is_debug()) {
+   return;
+  }
+  log.debug("After expansion of %s gen with boundary move", old ? "old" : "young");
+  ResourceMark rm;
+  ParallelScavengeHeap::heap()->print_on(log.debug_stream());
+  log.debug("  PS%sGen max size: " SIZE_FORMAT "K", old ? "Old" : "Young", max_size/K);
+}
 
 // Make checks on the current sizes of the generations and
 // the constraints on the sizes of the generations.  Push
@@ -141,17 +167,7 @@
     return;
   }
 
-  if (TraceAdaptiveGCBoundary) {
-    gclog_or_tty->print_cr("Before expansion of old gen with boundary move");
-    gclog_or_tty->print_cr("  Requested change: " SIZE_FORMAT_HEX
-                           "  Attempted change: " SIZE_FORMAT_HEX,
-      expand_in_bytes, change_in_bytes);
-    if (!PrintHeapAtGC) {
-      Universe::print_on(gclog_or_tty);
-    }
-    gclog_or_tty->print_cr("  PSOldGen max size: " SIZE_FORMAT "K",
-      old_gen()->max_gen_size()/K);
-  }
+  log_before_expansion(true, expand_in_bytes, change_in_bytes, old_gen()->max_gen_size());
 
   // Move the boundary between the generations up (smaller young gen).
   if (virtual_spaces()->adjust_boundary_up(change_in_bytes)) {
@@ -167,14 +183,7 @@
   young_gen()->space_invariants();
   old_gen()->space_invariants();
 
-  if (TraceAdaptiveGCBoundary) {
-    gclog_or_tty->print_cr("After expansion of old gen with boundary move");
-    if (!PrintHeapAtGC) {
-      Universe::print_on(gclog_or_tty);
-    }
-    gclog_or_tty->print_cr("  PSOldGen max size: " SIZE_FORMAT "K",
-      old_gen()->max_gen_size()/K);
-  }
+  log_after_expansion(true, old_gen()->max_gen_size());
 }
 
 // See comments on request_old_gen_expansion()
@@ -200,16 +209,7 @@
     return false;
   }
 
-  if (TraceAdaptiveGCBoundary) {
-    gclog_or_tty->print_cr("Before expansion of young gen with boundary move");
-    gclog_or_tty->print_cr("  Requested change: " SIZE_FORMAT_HEX "  Attempted change: " SIZE_FORMAT_HEX,
-      expand_in_bytes, change_in_bytes);
-    if (!PrintHeapAtGC) {
-      Universe::print_on(gclog_or_tty);
-    }
-    gclog_or_tty->print_cr("  PSYoungGen max size: " SIZE_FORMAT "K",
-      young_gen()->max_size()/K);
-  }
+  log_before_expansion(false, expand_in_bytes, change_in_bytes, young_gen()->max_size());
 
   // Move the boundary between the generations down (smaller old gen).
   MutexLocker x(ExpandHeap_lock);
@@ -227,14 +227,7 @@
   young_gen()->space_invariants();
   old_gen()->space_invariants();
 
-  if (TraceAdaptiveGCBoundary) {
-    gclog_or_tty->print_cr("After expansion of young gen with boundary move");
-    if (!PrintHeapAtGC) {
-      Universe::print_on(gclog_or_tty);
-    }
-    gclog_or_tty->print_cr("  PSYoungGen max size: " SIZE_FORMAT "K",
-      young_gen()->max_size()/K);
-  }
+  log_after_expansion(false, young_gen()->max_size());
 
   return result;
 }
--- a/src/share/vm/gc/parallel/asPSOldGen.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/asPSOldGen.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -125,25 +125,21 @@
   size_t result = policy->promo_increment_aligned_down(max_contraction);
   // Also adjust for inter-generational alignment
   size_t result_aligned = align_size_down(result, gen_alignment);
-  if (PrintAdaptiveSizePolicy && Verbose) {
-    gclog_or_tty->print_cr("\nASPSOldGen::available_for_contraction:"
-      " " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, result_aligned/K, result_aligned);
-    gclog_or_tty->print_cr(" reserved().byte_size() " SIZE_FORMAT " K / " SIZE_FORMAT_HEX,
-      reserved().byte_size()/K, reserved().byte_size());
+
+  LogHandle(gc, ergo) log;
+  if (log.is_trace()) {
     size_t working_promoted = (size_t) policy->avg_promoted()->padded_average();
-    gclog_or_tty->print_cr(" padded promoted " SIZE_FORMAT " K / " SIZE_FORMAT_HEX,
-      working_promoted/K, working_promoted);
-    gclog_or_tty->print_cr(" used " SIZE_FORMAT " K / " SIZE_FORMAT_HEX,
-      used_in_bytes()/K, used_in_bytes());
-    gclog_or_tty->print_cr(" min_gen_size() " SIZE_FORMAT " K / " SIZE_FORMAT_HEX,
-      min_gen_size()/K, min_gen_size());
-    gclog_or_tty->print_cr(" max_contraction " SIZE_FORMAT " K / " SIZE_FORMAT_HEX,
-      max_contraction/K, max_contraction);
-    gclog_or_tty->print_cr("    without alignment " SIZE_FORMAT " K / " SIZE_FORMAT_HEX,
-      policy->promo_increment(max_contraction)/K,
-      policy->promo_increment(max_contraction));
-    gclog_or_tty->print_cr(" alignment " SIZE_FORMAT_HEX, gen_alignment);
+    size_t promo_increment = policy->promo_increment(max_contraction);
+    log.trace("ASPSOldGen::available_for_contraction: " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, result_aligned/K, result_aligned);
+    log.trace(" reserved().byte_size() " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, reserved().byte_size()/K, reserved().byte_size());
+    log.trace(" padded promoted " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, working_promoted/K, working_promoted);
+    log.trace(" used " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, used_in_bytes()/K, used_in_bytes());
+    log.trace(" min_gen_size() " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, min_gen_size()/K, min_gen_size());
+    log.trace(" max_contraction " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, max_contraction/K, max_contraction);
+    log.trace("    without alignment " SIZE_FORMAT " K / " SIZE_FORMAT_HEX, promo_increment/K, promo_increment);
+    log.trace(" alignment " SIZE_FORMAT_HEX, gen_alignment);
   }
+
   assert(result_aligned <= max_contraction, "arithmetic is wrong");
   return result_aligned;
 }
--- a/src/share/vm/gc/parallel/asPSYoungGen.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/asPSYoungGen.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -111,13 +111,12 @@
     PSAdaptiveSizePolicy* policy = heap->size_policy();
     size_t result = policy->eden_increment_aligned_down(max_contraction);
     size_t result_aligned = align_size_down(result, gen_alignment);
-    if (PrintAdaptiveSizePolicy && Verbose) {
-      gclog_or_tty->print_cr("ASPSYoungGen::available_for_contraction: " SIZE_FORMAT " K",
-        result_aligned/K);
-      gclog_or_tty->print_cr("  max_contraction " SIZE_FORMAT " K", max_contraction/K);
-      gclog_or_tty->print_cr("  eden_avail " SIZE_FORMAT " K", eden_avail/K);
-      gclog_or_tty->print_cr("  gen_avail " SIZE_FORMAT " K", gen_avail/K);
-    }
+
+    log_trace(gc, ergo)("ASPSYoungGen::available_for_contraction: " SIZE_FORMAT " K", result_aligned/K);
+    log_trace(gc, ergo)("  max_contraction " SIZE_FORMAT " K", max_contraction/K);
+    log_trace(gc, ergo)("  eden_avail " SIZE_FORMAT " K", eden_avail/K);
+    log_trace(gc, ergo)("  gen_avail " SIZE_FORMAT " K", gen_avail/K);
+
     return result_aligned;
   }
 
@@ -199,25 +198,17 @@
     virtual_space()->shrink_by(change);
     size_changed = true;
   } else {
-    if (Verbose && PrintGC) {
-      if (orig_size == gen_size_limit()) {
-        gclog_or_tty->print_cr("ASPSYoung generation size at maximum: "
-          SIZE_FORMAT "K", orig_size/K);
-      } else if (orig_size == min_gen_size()) {
-        gclog_or_tty->print_cr("ASPSYoung generation size at minium: "
-          SIZE_FORMAT "K", orig_size/K);
-      }
+    if (orig_size == gen_size_limit()) {
+      log_trace(gc)("ASPSYoung generation size at maximum: " SIZE_FORMAT "K", orig_size/K);
+    } else if (orig_size == min_gen_size()) {
+      log_trace(gc)("ASPSYoung generation size at minium: " SIZE_FORMAT "K", orig_size/K);
     }
   }
 
   if (size_changed) {
     reset_after_change();
-    if (Verbose && PrintGC) {
-      size_t current_size  = virtual_space()->committed_size();
-      gclog_or_tty->print_cr("ASPSYoung generation size changed: "
-        SIZE_FORMAT "K->" SIZE_FORMAT "K",
-        orig_size/K, current_size/K);
-    }
+    log_trace(gc)("ASPSYoung generation size changed: " SIZE_FORMAT "K->" SIZE_FORMAT "K",
+                  orig_size/K, virtual_space()->committed_size()/K);
   }
 
   guarantee(eden_plus_survivors <= virtual_space()->committed_size() ||
@@ -245,41 +236,31 @@
     return;
   }
 
-  if (PrintAdaptiveSizePolicy && Verbose) {
-    gclog_or_tty->print_cr("PSYoungGen::resize_spaces(requested_eden_size: "
-                  SIZE_FORMAT
-                  ", requested_survivor_size: " SIZE_FORMAT ")",
-                  requested_eden_size, requested_survivor_size);
-    gclog_or_tty->print_cr("    eden: [" PTR_FORMAT ".." PTR_FORMAT ") "
-                  SIZE_FORMAT,
-                  p2i(eden_space()->bottom()),
-                  p2i(eden_space()->end()),
-                  pointer_delta(eden_space()->end(),
-                                eden_space()->bottom(),
-                                sizeof(char)));
-    gclog_or_tty->print_cr("    from: [" PTR_FORMAT ".." PTR_FORMAT ") "
-                  SIZE_FORMAT,
-                  p2i(from_space()->bottom()),
-                  p2i(from_space()->end()),
-                  pointer_delta(from_space()->end(),
-                                from_space()->bottom(),
-                                sizeof(char)));
-    gclog_or_tty->print_cr("      to: [" PTR_FORMAT ".." PTR_FORMAT ") "
-                  SIZE_FORMAT,
-                  p2i(to_space()->bottom()),
-                  p2i(to_space()->end()),
-                  pointer_delta(  to_space()->end(),
-                                  to_space()->bottom(),
-                                  sizeof(char)));
-  }
+  log_trace(gc, ergo)("PSYoungGen::resize_spaces(requested_eden_size: "
+                      SIZE_FORMAT
+                      ", requested_survivor_size: " SIZE_FORMAT ")",
+                      requested_eden_size, requested_survivor_size);
+  log_trace(gc, ergo)("    eden: [" PTR_FORMAT ".." PTR_FORMAT ") "
+                      SIZE_FORMAT,
+                      p2i(eden_space()->bottom()),
+                      p2i(eden_space()->end()),
+                      pointer_delta(eden_space()->end(), eden_space()->bottom(), sizeof(char)));
+  log_trace(gc, ergo)("    from: [" PTR_FORMAT ".." PTR_FORMAT ") "
+                      SIZE_FORMAT,
+                      p2i(from_space()->bottom()),
+                      p2i(from_space()->end()),
+                      pointer_delta(from_space()->end(), from_space()->bottom(), sizeof(char)));
+  log_trace(gc, ergo)("      to: [" PTR_FORMAT ".." PTR_FORMAT ") "
+                      SIZE_FORMAT,
+                      p2i(to_space()->bottom()),
+                      p2i(to_space()->end()),
+                      pointer_delta(  to_space()->end(), to_space()->bottom(), sizeof(char)));
 
   // There's nothing to do if the new sizes are the same as the current
   if (requested_survivor_size == to_space()->capacity_in_bytes() &&
       requested_survivor_size == from_space()->capacity_in_bytes() &&
       requested_eden_size == eden_space()->capacity_in_bytes()) {
-    if (PrintAdaptiveSizePolicy && Verbose) {
-      gclog_or_tty->print_cr("    capacities are the right sizes, returning");
-    }
+    log_trace(gc, ergo)("    capacities are the right sizes, returning");
     return;
   }
 
@@ -302,9 +283,7 @@
   if (eden_from_to_order) {
     // Eden, from, to
 
-    if (PrintAdaptiveSizePolicy && Verbose) {
-      gclog_or_tty->print_cr("  Eden, from, to:");
-    }
+    log_trace(gc, ergo)("  Eden, from, to:");
 
     // Set eden
     // "requested_eden_size" is a goal for the size of eden
@@ -368,28 +347,24 @@
 
     guarantee(to_start != to_end, "to space is zero sized");
 
-    if (PrintAdaptiveSizePolicy && Verbose) {
-      gclog_or_tty->print_cr("    [eden_start .. eden_end): "
-                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
-                    p2i(eden_start),
-                    p2i(eden_end),
-                    pointer_delta(eden_end, eden_start, sizeof(char)));
-      gclog_or_tty->print_cr("    [from_start .. from_end): "
-                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
-                    p2i(from_start),
-                    p2i(from_end),
-                    pointer_delta(from_end, from_start, sizeof(char)));
-      gclog_or_tty->print_cr("    [  to_start ..   to_end): "
-                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
-                    p2i(to_start),
-                    p2i(to_end),
-                    pointer_delta(  to_end,   to_start, sizeof(char)));
-    }
+    log_trace(gc, ergo)("    [eden_start .. eden_end): "
+                        "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
+                        p2i(eden_start),
+                        p2i(eden_end),
+                        pointer_delta(eden_end, eden_start, sizeof(char)));
+    log_trace(gc, ergo)("    [from_start .. from_end): "
+                        "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
+                        p2i(from_start),
+                        p2i(from_end),
+                        pointer_delta(from_end, from_start, sizeof(char)));
+    log_trace(gc, ergo)("    [  to_start ..   to_end): "
+                        "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
+                        p2i(to_start),
+                        p2i(to_end),
+                        pointer_delta(  to_end,   to_start, sizeof(char)));
   } else {
     // Eden, to, from
-    if (PrintAdaptiveSizePolicy && Verbose) {
-      gclog_or_tty->print_cr("  Eden, to, from:");
-    }
+    log_trace(gc, ergo)("  Eden, to, from:");
 
     // To space gets priority over eden resizing. Note that we position
     // to space as if we were able to resize from space, even though from
@@ -422,23 +397,21 @@
     eden_end = MAX2(eden_end, eden_start + alignment);
     to_start = MAX2(to_start, eden_end);
 
-    if (PrintAdaptiveSizePolicy && Verbose) {
-      gclog_or_tty->print_cr("    [eden_start .. eden_end): "
-                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
-                    p2i(eden_start),
-                    p2i(eden_end),
-                    pointer_delta(eden_end, eden_start, sizeof(char)));
-      gclog_or_tty->print_cr("    [  to_start ..   to_end): "
-                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
-                    p2i(to_start),
-                    p2i(to_end),
-                    pointer_delta(  to_end,   to_start, sizeof(char)));
-      gclog_or_tty->print_cr("    [from_start .. from_end): "
-                    "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
-                    p2i(from_start),
-                    p2i(from_end),
-                    pointer_delta(from_end, from_start, sizeof(char)));
-    }
+    log_trace(gc, ergo)("    [eden_start .. eden_end): "
+                        "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
+                        p2i(eden_start),
+                        p2i(eden_end),
+                        pointer_delta(eden_end, eden_start, sizeof(char)));
+    log_trace(gc, ergo)("    [  to_start ..   to_end): "
+                        "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
+                        p2i(to_start),
+                        p2i(to_end),
+                        pointer_delta(  to_end,   to_start, sizeof(char)));
+    log_trace(gc, ergo)("    [from_start .. from_end): "
+                        "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT,
+                        p2i(from_start),
+                        p2i(from_end),
+                        pointer_delta(from_end, from_start, sizeof(char)));
   }
 
 
@@ -457,7 +430,7 @@
   // Let's make sure the call to initialize doesn't reset "top"!
   DEBUG_ONLY(HeapWord* old_from_top = from_space()->top();)
 
-  // For PrintAdaptiveSizePolicy block  below
+  // For logging block  below
   size_t old_from = from_space()->capacity_in_bytes();
   size_t old_to   = to_space()->capacity_in_bytes();
 
@@ -506,19 +479,16 @@
 
   assert(from_space()->top() == old_from_top, "from top changed!");
 
-  if (PrintAdaptiveSizePolicy) {
-    ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
-    gclog_or_tty->print("AdaptiveSizePolicy::survivor space sizes: "
-                  "collection: %d "
-                  "(" SIZE_FORMAT ", " SIZE_FORMAT ") -> "
-                  "(" SIZE_FORMAT ", " SIZE_FORMAT ") ",
-                  heap->total_collections(),
-                  old_from, old_to,
-                  from_space()->capacity_in_bytes(),
-                  to_space()->capacity_in_bytes());
-    gclog_or_tty->cr();
-  }
-  space_invariants();
+  log_trace(gc, ergo)("AdaptiveSizePolicy::survivor space sizes: "
+                "collection: %d "
+                "(" SIZE_FORMAT ", " SIZE_FORMAT ") -> "
+                "(" SIZE_FORMAT ", " SIZE_FORMAT ") ",
+                ParallelScavengeHeap::heap()->total_collections(),
+                old_from, old_to,
+                from_space()->capacity_in_bytes(),
+                to_space()->capacity_in_bytes());
+
+    space_invariants();
 }
 void ASPSYoungGen::reset_after_change() {
   assert_locked_or_safepoint(Heap_lock);
--- a/src/share/vm/gc/parallel/cardTableExtension.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/cardTableExtension.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -468,30 +468,17 @@
   // Update the covered region
   resize_update_covered_table(changed_region, new_region);
 
-  if (TraceCardTableModRefBS) {
-    int ind = changed_region;
-    gclog_or_tty->print_cr("CardTableModRefBS::resize_covered_region: ");
-    gclog_or_tty->print_cr("  "
-                  "  _covered[%d].start(): " INTPTR_FORMAT
-                  "  _covered[%d].last(): " INTPTR_FORMAT,
-                  ind, p2i(_covered[ind].start()),
-                  ind, p2i(_covered[ind].last()));
-    gclog_or_tty->print_cr("  "
-                  "  _committed[%d].start(): " INTPTR_FORMAT
-                  "  _committed[%d].last(): " INTPTR_FORMAT,
-                  ind, p2i(_committed[ind].start()),
-                  ind, p2i(_committed[ind].last()));
-    gclog_or_tty->print_cr("  "
-                  "  byte_for(start): " INTPTR_FORMAT
-                  "  byte_for(last): " INTPTR_FORMAT,
-                  p2i(byte_for(_covered[ind].start())),
-                  p2i(byte_for(_covered[ind].last())));
-    gclog_or_tty->print_cr("  "
-                  "  addr_for(start): " INTPTR_FORMAT
-                  "  addr_for(last): " INTPTR_FORMAT,
-                  p2i(addr_for((jbyte*) _committed[ind].start())),
-                  p2i(addr_for((jbyte*) _committed[ind].last())));
-  }
+  int ind = changed_region;
+  log_trace(gc, barrier)("CardTableModRefBS::resize_covered_region: ");
+  log_trace(gc, barrier)("    _covered[%d].start(): " INTPTR_FORMAT "  _covered[%d].last(): " INTPTR_FORMAT,
+                ind, p2i(_covered[ind].start()), ind, p2i(_covered[ind].last()));
+  log_trace(gc, barrier)("    _committed[%d].start(): " INTPTR_FORMAT "  _committed[%d].last(): " INTPTR_FORMAT,
+                ind, p2i(_committed[ind].start()), ind, p2i(_committed[ind].last()));
+  log_trace(gc, barrier)("    byte_for(start): " INTPTR_FORMAT "  byte_for(last): " INTPTR_FORMAT,
+                p2i(byte_for(_covered[ind].start())),  p2i(byte_for(_covered[ind].last())));
+  log_trace(gc, barrier)("    addr_for(start): " INTPTR_FORMAT "  addr_for(last): " INTPTR_FORMAT,
+                p2i(addr_for((jbyte*) _committed[ind].start())), p2i(addr_for((jbyte*) _committed[ind].last())));
+
   debug_only(verify_guard();)
 }
 
--- a/src/share/vm/gc/parallel/gcTaskManager.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/gcTaskManager.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -27,6 +27,7 @@
 #include "gc/parallel/gcTaskThread.hpp"
 #include "gc/shared/adaptiveSizePolicy.hpp"
 #include "gc/shared/gcId.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.hpp"
 #include "memory/allocation.inline.hpp"
 #include "runtime/mutex.hpp"
@@ -465,13 +466,11 @@
          "all_workers_active() is  incorrect: "
          "active %d  ParallelGCThreads %u", active_workers(),
          ParallelGCThreads);
-  if (TraceDynamicGCThreads) {
-    gclog_or_tty->print_cr("GCTaskManager::set_active_gang(): "
-                           "all_workers_active()  %d  workers %d  "
-                           "active  %d  ParallelGCThreads %u",
-                           all_workers_active(), workers(),  active_workers(),
-                           ParallelGCThreads);
-  }
+  log_trace(gc, task)("GCTaskManager::set_active_gang(): "
+                      "all_workers_active()  %d  workers %d  "
+                      "active  %d  ParallelGCThreads %u",
+                      all_workers_active(), workers(),  active_workers(),
+                      ParallelGCThreads);
 }
 
 // Create IdleGCTasks for inactive workers.
@@ -502,15 +501,12 @@
         set_active_workers(reduced_active_workers);
         more_inactive_workers = 0;
       }
-      if (TraceDynamicGCThreads) {
-        gclog_or_tty->print_cr("JT: %d  workers %d  active  %d  "
-                                "idle %d  more %d",
-                                Threads::number_of_non_daemon_threads(),
-                                workers(),
-                                active_workers(),
-                                idle_workers(),
-                                more_inactive_workers);
-      }
+      log_trace(gc, task)("JT: %d  workers %d  active  %d  idle %d  more %d",
+                          Threads::number_of_non_daemon_threads(),
+                          workers(),
+                          active_workers(),
+                          idle_workers(),
+                          more_inactive_workers);
     }
     GCTaskQueue* q = GCTaskQueue::create();
     for(uint i = 0; i < (uint) more_inactive_workers; i++) {
@@ -536,6 +532,9 @@
 }
 
 void GCTaskManager::print_task_time_stamps() {
+  if (!log_is_enabled(Debug, gc, task, time)) {
+    return;
+  }
   for(uint i=0; i<ParallelGCThreads; i++) {
     GCTaskThread* t = thread(i);
     t->print_task_time_stamps();
@@ -828,38 +827,24 @@
 
 void IdleGCTask::do_it(GCTaskManager* manager, uint which) {
   WaitHelper* wait_helper = manager->wait_helper();
-  if (TraceGCTaskManager) {
-    tty->print_cr("[" INTPTR_FORMAT "]"
-                  " IdleGCTask:::do_it()"
-      "  should_wait: %s",
+  log_trace(gc, task)("[" INTPTR_FORMAT "] IdleGCTask:::do_it() should_wait: %s",
       p2i(this), wait_helper->should_wait() ? "true" : "false");
-  }
+
   MutexLockerEx ml(manager->monitor(), Mutex::_no_safepoint_check_flag);
-  if (TraceDynamicGCThreads) {
-    gclog_or_tty->print_cr("--- idle %d", which);
-  }
+  log_trace(gc, task)("--- idle %d", which);
   // Increment has to be done when the idle tasks are created.
   // manager->increment_idle_workers();
   manager->monitor()->notify_all();
   while (wait_helper->should_wait()) {
-    if (TraceGCTaskManager) {
-      tty->print_cr("[" INTPTR_FORMAT "]"
-                    " IdleGCTask::do_it()"
-        "  [" INTPTR_FORMAT "] (%s)->wait()",
-        p2i(this), p2i(manager->monitor()), manager->monitor()->name());
-    }
+    log_trace(gc, task)("[" INTPTR_FORMAT "] IdleGCTask::do_it()  [" INTPTR_FORMAT "] (%s)->wait()",
+      p2i(this), p2i(manager->monitor()), manager->monitor()->name());
     manager->monitor()->wait(Mutex::_no_safepoint_check_flag, 0);
   }
   manager->decrement_idle_workers();
-  if (TraceDynamicGCThreads) {
-    gclog_or_tty->print_cr("--- release %d", which);
-  }
-  if (TraceGCTaskManager) {
-    tty->print_cr("[" INTPTR_FORMAT "]"
-                  " IdleGCTask::do_it() returns"
-      "  should_wait: %s",
-      p2i(this), wait_helper->should_wait() ? "true" : "false");
-  }
+
+  log_trace(gc, task)("--- release %d", which);
+  log_trace(gc, task)("[" INTPTR_FORMAT "] IdleGCTask::do_it() returns should_wait: %s",
+    p2i(this), wait_helper->should_wait() ? "true" : "false");
   // Release monitor().
 }
 
--- a/src/share/vm/gc/parallel/gcTaskThread.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/gcTaskThread.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -26,9 +26,11 @@
 #include "gc/parallel/gcTaskManager.hpp"
 #include "gc/parallel/gcTaskThread.hpp"
 #include "gc/shared/gcId.hpp"
+#include "logging/log.hpp"
 #include "memory/allocation.hpp"
 #include "memory/allocation.inline.hpp"
 #include "memory/resourceArea.hpp"
+#include "runtime/atomic.inline.hpp"
 #include "runtime/handles.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/os.hpp"
@@ -45,11 +47,6 @@
   if (!os::create_thread(this, os::pgc_thread))
     vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GC thread. Out of system resources.");
 
-  if (PrintGCTaskTimeStamps) {
-    _time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
-
-    guarantee(_time_stamps != NULL, "Sanity");
-  }
   set_id(which);
   set_name("ParGC Thread#%d", which);
 }
@@ -66,21 +63,30 @@
 
 GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) {
   guarantee(index < GCTaskTimeStampEntries, "increase GCTaskTimeStampEntries");
+  if (_time_stamps == NULL) {
+    // We allocate the _time_stamps array lazily since logging can be enabled dynamically
+    GCTaskTimeStamp* time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
+    void* old = Atomic::cmpxchg_ptr(time_stamps, &_time_stamps, NULL);
+    if (old != NULL) {
+      // Someone already setup the time stamps
+      FREE_C_HEAP_ARRAY(GCTaskTimeStamp, time_stamps);
+    }
+  }
 
   return &(_time_stamps[index]);
 }
 
 void GCTaskThread::print_task_time_stamps() {
-  assert(PrintGCTaskTimeStamps, "Sanity");
-  assert(_time_stamps != NULL, "Sanity (Probably set PrintGCTaskTimeStamps late)");
+  assert(log_is_enabled(Debug, gc, task, time), "Sanity");
+  assert(_time_stamps != NULL, "Sanity");
 
-  tty->print_cr("GC-Thread %u entries: %d", id(), _time_stamp_index);
+  log_debug(gc, task, time)("GC-Thread %u entries: %d", id(), _time_stamp_index);
   for(uint i=0; i<_time_stamp_index; i++) {
     GCTaskTimeStamp* time_stamp = time_stamp_at(i);
-    tty->print_cr("\t[ %s " JLONG_FORMAT " " JLONG_FORMAT " ]",
-                  time_stamp->name(),
-                  time_stamp->entry_time(),
-                  time_stamp->exit_time());
+    log_debug(gc, task, time)("\t[ %s " JLONG_FORMAT " " JLONG_FORMAT " ]",
+                              time_stamp->name(),
+                              time_stamp->entry_time(),
+                              time_stamp->exit_time());
   }
 
   // Reset after dumping the data
@@ -127,7 +133,7 @@
       // Record if this is an idle task for later use.
       bool is_idle_task = task->is_idle_task();
       // In case the update is costly
-      if (PrintGCTaskTimeStamps) {
+      if (log_is_enabled(Debug, gc, task, time)) {
         timer.update();
       }
 
@@ -143,10 +149,7 @@
       if (!is_idle_task) {
         manager()->note_completion(which());
 
-        if (PrintGCTaskTimeStamps) {
-          assert(_time_stamps != NULL,
-            "Sanity (PrintGCTaskTimeStamps set late?)");
-
+        if (log_is_enabled(Debug, gc, task, time)) {
           timer.update();
 
           GCTaskTimeStamp* time_stamp = time_stamp_at(_time_stamp_index++);
--- a/src/share/vm/gc/parallel/parallelScavengeHeap.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/parallelScavengeHeap.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -38,6 +38,7 @@
 #include "gc/shared/gcHeapSummary.hpp"
 #include "gc/shared/gcLocker.inline.hpp"
 #include "gc/shared/gcWhen.hpp"
+#include "logging/log.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/java.hpp"
@@ -307,10 +308,7 @@
         if (limit_exceeded && softrefs_clear) {
           *gc_overhead_limit_was_exceeded = true;
           size_policy()->set_gc_overhead_limit_exceeded(false);
-          if (PrintGCDetails && Verbose) {
-            gclog_or_tty->print_cr("ParallelScavengeHeap::mem_allocate: "
-              "return NULL because gc_overhead_limit_exceeded is set");
-          }
+          log_trace(gc)("ParallelScavengeHeap::mem_allocate: return NULL because gc_overhead_limit_exceeded is set");
           if (op.result() != NULL) {
             CollectedHeap::fill_with_object(op.result(), size);
           }
@@ -584,35 +582,17 @@
 }
 
 
-void ParallelScavengeHeap::verify(bool silent, VerifyOption option /* ignored */) {
+void ParallelScavengeHeap::verify(VerifyOption option /* ignored */) {
   // Why do we need the total_collections()-filter below?
   if (total_collections() > 0) {
-    if (!silent) {
-      gclog_or_tty->print("tenured ");
-    }
+    log_debug(gc, verify)("Tenured");
     old_gen()->verify();
 
-    if (!silent) {
-      gclog_or_tty->print("eden ");
-    }
+    log_debug(gc, verify)("Eden");
     young_gen()->verify();
   }
 }
 
-void ParallelScavengeHeap::print_heap_change(size_t prev_used) {
-  if (PrintGCDetails && Verbose) {
-    gclog_or_tty->print(" "  SIZE_FORMAT
-                        "->" SIZE_FORMAT
-                        "("  SIZE_FORMAT ")",
-                        prev_used, used(), capacity());
-  } else {
-    gclog_or_tty->print(" "  SIZE_FORMAT "K"
-                        "->" SIZE_FORMAT "K"
-                        "("  SIZE_FORMAT "K)",
-                        prev_used / K, used() / K, capacity() / K);
-  }
-}
-
 void ParallelScavengeHeap::trace_heap(GCWhen::Type when, const GCTracer* gc_tracer) {
   const PSHeapSummary& heap_summary = create_ps_heap_summary();
   gc_tracer->report_gc_heap_summary(when, heap_summary);
--- a/src/share/vm/gc/parallel/parallelScavengeHeap.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/parallelScavengeHeap.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -35,6 +35,7 @@
 #include "gc/shared/gcPolicyCounters.hpp"
 #include "gc/shared/gcWhen.hpp"
 #include "gc/shared/strongRootsScope.hpp"
+#include "memory/metaspace.hpp"
 #include "utilities/ostream.hpp"
 
 class AdjoiningGenerations;
@@ -87,6 +88,10 @@
     return CollectedHeap::ParallelScavengeHeap;
   }
 
+  virtual const char* name() const {
+    return "Parallel";
+  }
+
   virtual CollectorPolicy* collector_policy() const { return _collector_policy; }
 
   static PSYoungGen* young_gen() { return _young_gen; }
@@ -215,9 +220,7 @@
   virtual void gc_threads_do(ThreadClosure* tc) const;
   virtual void print_tracing_info() const;
 
-  void verify(bool silent, VerifyOption option /* ignored */);
-
-  void print_heap_change(size_t prev_used);
+  void verify(VerifyOption option /* ignored */);
 
   // Resize the young generation.  The reserved space for the
   // generation may be expanded in preparation for the resize.
@@ -241,4 +244,26 @@
   };
 };
 
+// Simple class for storing info about the heap at the start of GC, to be used
+// after GC for comparison/printing.
+class PreGCValues {
+public:
+  PreGCValues(ParallelScavengeHeap* heap) :
+      _heap_used(heap->used()),
+      _young_gen_used(heap->young_gen()->used_in_bytes()),
+      _old_gen_used(heap->old_gen()->used_in_bytes()),
+      _metadata_used(MetaspaceAux::used_bytes()) { };
+
+  size_t heap_used() const      { return _heap_used; }
+  size_t young_gen_used() const { return _young_gen_used; }
+  size_t old_gen_used() const   { return _old_gen_used; }
+  size_t metadata_used() const  { return _metadata_used; }
+
+private:
+  size_t _heap_used;
+  size_t _young_gen_used;
+  size_t _old_gen_used;
+  size_t _metadata_used;
+};
+
 #endif // SHARE_VM_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
--- a/src/share/vm/gc/parallel/pcTasks.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/pcTasks.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -31,7 +31,8 @@
 #include "gc/parallel/psParallelCompact.hpp"
 #include "gc/shared/collectedHeap.hpp"
 #include "gc/shared/gcTimer.hpp"
-#include "gc/shared/gcTraceTime.hpp"
+#include "gc/shared/gcTraceTime.inline.hpp"
+#include "logging/log.hpp"
 #include "memory/universe.hpp"
 #include "oops/objArrayKlass.inline.hpp"
 #include "oops/oop.inline.hpp"
@@ -251,14 +252,6 @@
 
   cm->set_region_stack_index(which_stack_index);
   cm->set_region_stack(ParCompactionManager::region_list(which_stack_index));
-  if (TraceDynamicGCThreads) {
-    gclog_or_tty->print_cr("StealRegionCompactionTask::do_it "
-                           "region_stack_index %d region_stack = " PTR_FORMAT " "
-                           " empty (%d) use all workers %d",
-    which_stack_index, p2i(ParCompactionManager::region_list(which_stack_index)),
-    cm->region_stack()->is_empty(),
-    use_all_workers);
-  }
 
   // Has to drain stacks first because there may be regions on
   // preloaded onto the stack and this thread may never have
@@ -323,14 +316,6 @@
   }
 
   cm->set_region_stack(ParCompactionManager::region_list(which_stack_index));
-  if (TraceDynamicGCThreads) {
-    gclog_or_tty->print_cr("DrainStacksCompactionTask::do_it which = %d "
-                           "which_stack_index = %d/empty(%d) "
-                           "use all workers %d",
-                           which, which_stack_index,
-                           cm->region_stack()->is_empty(),
-                           use_all_workers);
-  }
 
   cm->set_region_stack_index(which_stack_index);
 
@@ -346,13 +331,6 @@
            "region_stack and region_stack_index are inconsistent");
     ParCompactionManager::push_recycled_stack_index(cm->region_stack_index());
 
-    if (TraceDynamicGCThreads) {
-      void* old_region_stack = (void*) cm->region_stack();
-      int old_region_stack_index = cm->region_stack_index();
-      gclog_or_tty->print_cr("Pushing region stack " PTR_FORMAT "/%d",
-        p2i(old_region_stack), old_region_stack_index);
-    }
-
     cm->set_region_stack(NULL);
     cm->set_region_stack_index((uint)max_uintx);
   }
--- a/src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/psAdaptiveSizePolicy.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -30,6 +30,7 @@
 #include "gc/shared/collectorPolicy.hpp"
 #include "gc/shared/gcCause.hpp"
 #include "gc/shared/gcPolicyCounters.hpp"
+#include "logging/log.hpp"
 #include "runtime/timer.hpp"
 #include "utilities/top.hpp"
 
@@ -159,14 +160,10 @@
     _major_pause_young_estimator->update(eden_size_in_mbytes,
       major_pause_in_ms);
 
-    if (PrintAdaptiveSizePolicy && Verbose) {
-      gclog_or_tty->print("psAdaptiveSizePolicy::major_collection_end: "
-        "major gc cost: %f  average: %f", collection_cost,
-        avg_major_gc_cost()->average());
-      gclog_or_tty->print_cr("  major pause: %f major period %f",
-        major_pause_in_ms,
-        _latest_major_mutator_interval_seconds * MILLIUNITS);
-    }
+    log_trace(gc, ergo)("psAdaptiveSizePolicy::major_collection_end: major gc cost: %f  average: %f",
+                        collection_cost,avg_major_gc_cost()->average());
+    log_trace(gc, ergo)("  major pause: %f major period %f",
+                        major_pause_in_ms, _latest_major_mutator_interval_seconds * MILLIUNITS);
 
     // Calculate variable used to estimate collection cost vs. gen sizes
     assert(collection_cost >= 0.0, "Expected to be non-negative");
@@ -197,19 +194,11 @@
   // A similar test is done in the scavenge's should_attempt_scavenge().  If
   // this is changed, decide if that test should also be changed.
   bool result = padded_average_promoted_in_bytes() > (float) old_free_in_bytes;
-  if (PrintGCDetails && Verbose) {
-    if (result) {
-      gclog_or_tty->print("  full after scavenge: ");
-    } else {
-      gclog_or_tty->print("  no full after scavenge: ");
-    }
-    gclog_or_tty->print_cr(" average_promoted " SIZE_FORMAT
-      " padded_average_promoted " SIZE_FORMAT
-      " free in old gen " SIZE_FORMAT,
-      (size_t) average_promoted_in_bytes(),
-      (size_t) padded_average_promoted_in_bytes(),
-      old_free_in_bytes);
-  }
+  log_trace(gc, ergo)("%s after scavenge average_promoted " SIZE_FORMAT " padded_average_promoted " SIZE_FORMAT " free in old gen " SIZE_FORMAT,
+                      result ? "Full" : "No full",
+                      (size_t) average_promoted_in_bytes(),
+                      (size_t) padded_average_promoted_in_bytes(),
+                      old_free_in_bytes);
   return result;
 }
 
@@ -361,26 +350,24 @@
 
   // Note we make the same tests as in the code block below;  the code
   // seems a little easier to read with the printing in another block.
-  if (PrintAdaptiveSizePolicy) {
-    if (desired_eden_size > eden_limit) {
-      gclog_or_tty->print_cr(
-            "PSAdaptiveSizePolicy::compute_eden_space_size limits:"
-            " desired_eden_size: " SIZE_FORMAT
-            " old_eden_size: " SIZE_FORMAT
-            " eden_limit: " SIZE_FORMAT
-            " cur_eden: " SIZE_FORMAT
-            " max_eden_size: " SIZE_FORMAT
-            " avg_young_live: " SIZE_FORMAT,
-            desired_eden_size, _eden_size, eden_limit, cur_eden,
-            max_eden_size, (size_t)avg_young_live()->average());
-    }
-    if (gc_cost() > gc_cost_limit) {
-      gclog_or_tty->print_cr(
-            "PSAdaptiveSizePolicy::compute_eden_space_size: gc time limit"
-            " gc_cost: %f "
-            " GCTimeLimit: " UINTX_FORMAT,
-            gc_cost(), GCTimeLimit);
-    }
+  if (desired_eden_size > eden_limit) {
+    log_debug(gc, ergo)(
+          "PSAdaptiveSizePolicy::compute_eden_space_size limits:"
+          " desired_eden_size: " SIZE_FORMAT
+          " old_eden_size: " SIZE_FORMAT
+          " eden_limit: " SIZE_FORMAT
+          " cur_eden: " SIZE_FORMAT
+          " max_eden_size: " SIZE_FORMAT
+          " avg_young_live: " SIZE_FORMAT,
+          desired_eden_size, _eden_size, eden_limit, cur_eden,
+          max_eden_size, (size_t)avg_young_live()->average());
+  }
+  if (gc_cost() > gc_cost_limit) {
+    log_debug(gc, ergo)(
+          "PSAdaptiveSizePolicy::compute_eden_space_size: gc time limit"
+          " gc_cost: %f "
+          " GCTimeLimit: " UINTX_FORMAT,
+          gc_cost(), GCTimeLimit);
   }
 
   // Align everything and make a final limit check
@@ -399,51 +386,26 @@
     desired_eden_size = MAX2(eden_limit, cur_eden);
   }
 
-  if (PrintAdaptiveSizePolicy) {
-    // Timing stats
-    gclog_or_tty->print(
-               "PSAdaptiveSizePolicy::compute_eden_space_size: costs"
-               " minor_time: %f"
-               " major_cost: %f"
-               " mutator_cost: %f"
-               " throughput_goal: %f",
-               minor_gc_cost(), major_gc_cost(), mutator_cost(),
-               _throughput_goal);
+  log_debug(gc, ergo)("PSAdaptiveSizePolicy::compute_eden_space_size: costs minor_time: %f major_cost: %f mutator_cost: %f throughput_goal: %f",
+             minor_gc_cost(), major_gc_cost(), mutator_cost(), _throughput_goal);
 
-    // We give more details if Verbose is set
-    if (Verbose) {
-      gclog_or_tty->print( " minor_pause: %f"
-                  " major_pause: %f"
-                  " minor_interval: %f"
-                  " major_interval: %f"
-                  " pause_goal: %f",
-                  _avg_minor_pause->padded_average(),
-                  _avg_major_pause->padded_average(),
-                  _avg_minor_interval->average(),
-                  _avg_major_interval->average(),
-                  gc_pause_goal_sec());
-    }
+  log_trace(gc, ergo)("Minor_pause: %f major_pause: %f minor_interval: %f major_interval: %fpause_goal: %f",
+                      _avg_minor_pause->padded_average(),
+                      _avg_major_pause->padded_average(),
+                      _avg_minor_interval->average(),
+                      _avg_major_interval->average(),
+                      gc_pause_goal_sec());
 
-    // Footprint stats
-    gclog_or_tty->print( " live_space: " SIZE_FORMAT
-                " free_space: " SIZE_FORMAT,
-                live_space(), free_space());
-    // More detail
-    if (Verbose) {
-      gclog_or_tty->print( " base_footprint: " SIZE_FORMAT
-                  " avg_young_live: " SIZE_FORMAT
-                  " avg_old_live: " SIZE_FORMAT,
-                  (size_t)_avg_base_footprint->average(),
-                  (size_t)avg_young_live()->average(),
-                  (size_t)avg_old_live()->average());
-    }
+  log_debug(gc, ergo)("Live_space: " SIZE_FORMAT " free_space: " SIZE_FORMAT,
+                      live_space(), free_space());
 
-    // And finally, our old and new sizes.
-    gclog_or_tty->print(" old_eden_size: " SIZE_FORMAT
-               " desired_eden_size: " SIZE_FORMAT,
-               _eden_size, desired_eden_size);
-    gclog_or_tty->cr();
-  }
+  log_trace(gc, ergo)("Base_footprint: " SIZE_FORMAT " avg_young_live: " SIZE_FORMAT " avg_old_live: " SIZE_FORMAT,
+                      (size_t)_avg_base_footprint->average(),
+                      (size_t)avg_young_live()->average(),
+                      (size_t)avg_old_live()->average());
+
+  log_debug(gc, ergo)("Old eden_size: " SIZE_FORMAT " desired_eden_size: " SIZE_FORMAT,
+                      _eden_size, desired_eden_size);
 
   set_eden_size(desired_eden_size);
 }
@@ -564,27 +526,25 @@
 
   // Note we make the same tests as in the code block below;  the code
   // seems a little easier to read with the printing in another block.
-  if (PrintAdaptiveSizePolicy) {
-    if (desired_promo_size > promo_limit)  {
-      // "free_in_old_gen" was the original value for used for promo_limit
-      size_t free_in_old_gen = (size_t)(max_old_gen_size - avg_old_live()->average());
-      gclog_or_tty->print_cr(
-            "PSAdaptiveSizePolicy::compute_old_gen_free_space limits:"
-            " desired_promo_size: " SIZE_FORMAT
-            " promo_limit: " SIZE_FORMAT
-            " free_in_old_gen: " SIZE_FORMAT
-            " max_old_gen_size: " SIZE_FORMAT
-            " avg_old_live: " SIZE_FORMAT,
-            desired_promo_size, promo_limit, free_in_old_gen,
-            max_old_gen_size, (size_t) avg_old_live()->average());
-    }
-    if (gc_cost() > gc_cost_limit) {
-      gclog_or_tty->print_cr(
-            "PSAdaptiveSizePolicy::compute_old_gen_free_space: gc time limit"
-            " gc_cost: %f "
-            " GCTimeLimit: " UINTX_FORMAT,
-            gc_cost(), GCTimeLimit);
-    }
+  if (desired_promo_size > promo_limit)  {
+    // "free_in_old_gen" was the original value for used for promo_limit
+    size_t free_in_old_gen = (size_t)(max_old_gen_size - avg_old_live()->average());
+    log_debug(gc, ergo)(
+          "PSAdaptiveSizePolicy::compute_old_gen_free_space limits:"
+          " desired_promo_size: " SIZE_FORMAT
+          " promo_limit: " SIZE_FORMAT
+          " free_in_old_gen: " SIZE_FORMAT
+          " max_old_gen_size: " SIZE_FORMAT
+          " avg_old_live: " SIZE_FORMAT,
+          desired_promo_size, promo_limit, free_in_old_gen,
+          max_old_gen_size, (size_t) avg_old_live()->average());
+  }
+  if (gc_cost() > gc_cost_limit) {
+    log_debug(gc, ergo)(
+          "PSAdaptiveSizePolicy::compute_old_gen_free_space: gc time limit"
+          " gc_cost: %f "
+          " GCTimeLimit: " UINTX_FORMAT,
+          gc_cost(), GCTimeLimit);
   }
 
   // Align everything and make a final limit check
@@ -596,51 +556,28 @@
   // And one last limit check, now that we've aligned things.
   desired_promo_size = MIN2(desired_promo_size, promo_limit);
 
-  if (PrintAdaptiveSizePolicy) {
-    // Timing stats
-    gclog_or_tty->print(
-               "PSAdaptiveSizePolicy::compute_old_gen_free_space: costs"
-               " minor_time: %f"
-               " major_cost: %f"
-               " mutator_cost: %f"
-               " throughput_goal: %f",
-               minor_gc_cost(), major_gc_cost(), mutator_cost(),
-               _throughput_goal);
+  // Timing stats
+  log_debug(gc, ergo)("PSAdaptiveSizePolicy::compute_old_gen_free_space: costs minor_time: %f major_cost: %f  mutator_cost: %f throughput_goal: %f",
+             minor_gc_cost(), major_gc_cost(), mutator_cost(), _throughput_goal);
 
-    // We give more details if Verbose is set
-    if (Verbose) {
-      gclog_or_tty->print( " minor_pause: %f"
-                  " major_pause: %f"
-                  " minor_interval: %f"
-                  " major_interval: %f"
-                  " pause_goal: %f",
-                  _avg_minor_pause->padded_average(),
-                  _avg_major_pause->padded_average(),
-                  _avg_minor_interval->average(),
-                  _avg_major_interval->average(),
-                  gc_pause_goal_sec());
-    }
+  log_trace(gc, ergo)("Minor_pause: %f major_pause: %f minor_interval: %f major_interval: %f pause_goal: %f",
+                      _avg_minor_pause->padded_average(),
+                      _avg_major_pause->padded_average(),
+                      _avg_minor_interval->average(),
+                      _avg_major_interval->average(),
+                      gc_pause_goal_sec());
 
-    // Footprint stats
-    gclog_or_tty->print( " live_space: " SIZE_FORMAT
-                " free_space: " SIZE_FORMAT,
-                live_space(), free_space());
-    // More detail
-    if (Verbose) {
-      gclog_or_tty->print( " base_footprint: " SIZE_FORMAT
-                  " avg_young_live: " SIZE_FORMAT
-                  " avg_old_live: " SIZE_FORMAT,
-                  (size_t)_avg_base_footprint->average(),
-                  (size_t)avg_young_live()->average(),
-                  (size_t)avg_old_live()->average());
-    }
+  // Footprint stats
+  log_debug(gc, ergo)("Live_space: " SIZE_FORMAT " free_space: " SIZE_FORMAT,
+                      live_space(), free_space());
 
-    // And finally, our old and new sizes.
-    gclog_or_tty->print(" old_promo_size: " SIZE_FORMAT
-               " desired_promo_size: " SIZE_FORMAT,
-               _promo_size, desired_promo_size);
-    gclog_or_tty->cr();
-  }
+  log_trace(gc, ergo)("Base_footprint: " SIZE_FORMAT " avg_young_live: " SIZE_FORMAT " avg_old_live: " SIZE_FORMAT,
+                      (size_t)_avg_base_footprint->average(),
+                      (size_t)avg_young_live()->average(),
+                      (size_t)avg_old_live()->average());
+
+  log_debug(gc, ergo)("Old promo_size: " SIZE_FORMAT " desired_promo_size: " SIZE_FORMAT,
+                      _promo_size, desired_promo_size);
 
   set_promo_size(desired_promo_size);
 }
@@ -719,14 +656,12 @@
     }
   }
 
-  if (PrintAdaptiveSizePolicy && Verbose) {
-    gclog_or_tty->print_cr(
-      "PSAdaptiveSizePolicy::adjust_promo_for_pause_time "
-      "adjusting gen sizes for major pause (avg %f goal %f). "
-      "desired_promo_size " SIZE_FORMAT " promo delta " SIZE_FORMAT,
-      _avg_major_pause->average(), gc_pause_goal_sec(),
-      *desired_promo_size_ptr, promo_heap_delta);
-  }
+  log_trace(gc, ergo)(
+    "PSAdaptiveSizePolicy::adjust_promo_for_pause_time "
+    "adjusting gen sizes for major pause (avg %f goal %f). "
+    "desired_promo_size " SIZE_FORMAT " promo delta " SIZE_FORMAT,
+    _avg_major_pause->average(), gc_pause_goal_sec(),
+    *desired_promo_size_ptr, promo_heap_delta);
 }
 
 void PSAdaptiveSizePolicy::adjust_eden_for_pause_time(bool is_full_gc,
@@ -740,14 +675,12 @@
   if (_avg_minor_pause->padded_average() > _avg_major_pause->padded_average()) {
     adjust_eden_for_minor_pause_time(is_full_gc, desired_eden_size_ptr);
   }
-  if (PrintAdaptiveSizePolicy && Verbose) {
-    gclog_or_tty->print_cr(
-      "PSAdaptiveSizePolicy::adjust_eden_for_pause_time "
-      "adjusting gen sizes for major pause (avg %f goal %f). "
-      "desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT,
-      _avg_major_pause->average(), gc_pause_goal_sec(),
-      *desired_eden_size_ptr, eden_heap_delta);
-  }
+  log_trace(gc, ergo)(
+    "PSAdaptiveSizePolicy::adjust_eden_for_pause_time "
+    "adjusting gen sizes for major pause (avg %f goal %f). "
+    "desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT,
+    _avg_major_pause->average(), gc_pause_goal_sec(),
+    *desired_eden_size_ptr, eden_heap_delta);
 }
 
 void PSAdaptiveSizePolicy::adjust_promo_for_throughput(bool is_full_gc,
@@ -761,13 +694,8 @@
     return;
   }
 
-  if (PrintAdaptiveSizePolicy && Verbose) {
-    gclog_or_tty->print("\nPSAdaptiveSizePolicy::adjust_promo_for_throughput("
-      "is_full: %d, promo: " SIZE_FORMAT "): ",
-      is_full_gc, *desired_promo_size_ptr);
-    gclog_or_tty->print_cr("mutator_cost %f  major_gc_cost %f "
-      "minor_gc_cost %f", mutator_cost(), major_gc_cost(), minor_gc_cost());
-  }
+  log_trace(gc, ergo)("PSAdaptiveSizePolicy::adjust_promo_for_throughput(is_full: %d, promo: " SIZE_FORMAT "): mutator_cost %f  major_gc_cost %f minor_gc_cost %f",
+                      is_full_gc, *desired_promo_size_ptr, mutator_cost(), major_gc_cost(), minor_gc_cost());
 
   // Tenured generation
   if (is_full_gc) {
@@ -780,12 +708,8 @@
       double scale_by_ratio = major_gc_cost() / gc_cost();
       scaled_promo_heap_delta =
         (size_t) (scale_by_ratio * (double) promo_heap_delta);
-      if (PrintAdaptiveSizePolicy && Verbose) {
-        gclog_or_tty->print_cr(
-          "Scaled tenured increment: " SIZE_FORMAT " by %f down to "
-          SIZE_FORMAT,
-          promo_heap_delta, scale_by_ratio, scaled_promo_heap_delta);
-      }
+      log_trace(gc, ergo)("Scaled tenured increment: " SIZE_FORMAT " by %f down to " SIZE_FORMAT,
+                          promo_heap_delta, scale_by_ratio, scaled_promo_heap_delta);
     } else if (major_gc_cost() >= 0.0) {
       // Scaling is not going to work.  If the major gc time is the
       // larger, give it a full increment.
@@ -839,13 +763,10 @@
         _old_gen_change_for_major_throughput++;
     }
 
-    if (PrintAdaptiveSizePolicy && Verbose) {
-      gclog_or_tty->print_cr(
-          "adjusting tenured gen for throughput (avg %f goal %f). "
-          "desired_promo_size " SIZE_FORMAT " promo_delta " SIZE_FORMAT ,
-          mutator_cost(), _throughput_goal,
-          *desired_promo_size_ptr, scaled_promo_heap_delta);
-    }
+    log_trace(gc, ergo)("Adjusting tenured gen for throughput (avg %f goal %f). desired_promo_size " SIZE_FORMAT " promo_delta " SIZE_FORMAT ,
+                        mutator_cost(),
+                        _throughput_goal,
+                        *desired_promo_size_ptr, scaled_promo_heap_delta);
   }
 }
 
@@ -860,13 +781,8 @@
     return;
   }
 
-  if (PrintAdaptiveSizePolicy && Verbose) {
-    gclog_or_tty->print("\nPSAdaptiveSizePolicy::adjust_eden_for_throughput("
-      "is_full: %d, cur_eden: " SIZE_FORMAT "): ",
-      is_full_gc, *desired_eden_size_ptr);
-    gclog_or_tty->print_cr("mutator_cost %f  major_gc_cost %f "
-      "minor_gc_cost %f", mutator_cost(), major_gc_cost(), minor_gc_cost());
-  }
+  log_trace(gc, ergo)("PSAdaptiveSizePolicy::adjust_eden_for_throughput(is_full: %d, cur_eden: " SIZE_FORMAT "): mutator_cost %f  major_gc_cost %f minor_gc_cost %f",
+                      is_full_gc, *desired_eden_size_ptr, mutator_cost(), major_gc_cost(), minor_gc_cost());
 
   // Young generation
   size_t scaled_eden_heap_delta = 0;
@@ -878,12 +794,8 @@
     assert(scale_by_ratio <= 1.0 && scale_by_ratio >= 0.0, "Scaling is wrong");
     scaled_eden_heap_delta =
       (size_t) (scale_by_ratio * (double) eden_heap_delta);
-    if (PrintAdaptiveSizePolicy && Verbose) {
-      gclog_or_tty->print_cr(
-        "Scaled eden increment: " SIZE_FORMAT " by %f down to "
-        SIZE_FORMAT,
-        eden_heap_delta, scale_by_ratio, scaled_eden_heap_delta);
-    }
+    log_trace(gc, ergo)("Scaled eden increment: " SIZE_FORMAT " by %f down to " SIZE_FORMAT,
+                        eden_heap_delta, scale_by_ratio, scaled_eden_heap_delta);
   } else if (minor_gc_cost() >= 0.0) {
     // Scaling is not going to work.  If the minor gc time is the
     // larger, give it a full increment.
@@ -936,13 +848,8 @@
       _young_gen_change_for_minor_throughput++;
   }
 
-  if (PrintAdaptiveSizePolicy && Verbose) {
-    gclog_or_tty->print_cr(
-        "adjusting eden for throughput (avg %f goal %f). desired_eden_size "
-        SIZE_FORMAT " eden delta " SIZE_FORMAT "\n",
-      mutator_cost(), _throughput_goal,
-        *desired_eden_size_ptr, scaled_eden_heap_delta);
-  }
+    log_trace(gc, ergo)("Adjusting eden for throughput (avg %f goal %f). desired_eden_size " SIZE_FORMAT " eden delta " SIZE_FORMAT,
+                        mutator_cost(), _throughput_goal, *desired_eden_size_ptr, scaled_eden_heap_delta);
 }
 
 size_t PSAdaptiveSizePolicy::adjust_promo_for_footprint(
@@ -955,15 +862,13 @@
 
   size_t reduced_size = desired_promo_size - change;
 
-  if (PrintAdaptiveSizePolicy && Verbose) {
-    gclog_or_tty->print_cr(
-      "AdaptiveSizePolicy::adjust_promo_for_footprint "
-      "adjusting tenured gen for footprint. "
-      "starting promo size " SIZE_FORMAT
-      " reduced promo size " SIZE_FORMAT
-      " promo delta " SIZE_FORMAT,
-      desired_promo_size, reduced_size, change );
-  }
+  log_trace(gc, ergo)(
+    "AdaptiveSizePolicy::adjust_promo_for_footprint "
+    "adjusting tenured gen for footprint. "
+    "starting promo size " SIZE_FORMAT
+    " reduced promo size " SIZE_FORMAT
+    " promo delta " SIZE_FORMAT,
+    desired_promo_size, reduced_size, change );
 
   assert(reduced_size <= desired_promo_size, "Inconsistent result");
   return reduced_size;
@@ -979,15 +884,13 @@
 
   size_t reduced_size = desired_eden_size - change;
 
-  if (PrintAdaptiveSizePolicy && Verbose) {
-    gclog_or_tty->print_cr(
-      "AdaptiveSizePolicy::adjust_eden_for_footprint "
-      "adjusting eden for footprint. "
-      " starting eden size " SIZE_FORMAT
-      " reduced eden size " SIZE_FORMAT
-      " eden delta " SIZE_FORMAT,
-      desired_eden_size, reduced_size, change);
-  }
+  log_trace(gc, ergo)(
+    "AdaptiveSizePolicy::adjust_eden_for_footprint "
+    "adjusting eden for footprint. "
+    " starting eden size " SIZE_FORMAT
+    " reduced eden size " SIZE_FORMAT
+    " eden delta " SIZE_FORMAT,
+    desired_eden_size, reduced_size, change);
 
   assert(reduced_size <= desired_eden_size, "Inconsistent result");
   return reduced_size;
@@ -1187,33 +1090,14 @@
   // the amount of old gen free space is less than what we expect to
   // promote).
 
-  if (PrintAdaptiveSizePolicy) {
-    // A little more detail if Verbose is on
-    if (Verbose) {
-      gclog_or_tty->print( "  avg_survived: %f"
-                  "  avg_deviation: %f",
-                  _avg_survived->average(),
-                  _avg_survived->deviation());
-    }
+  log_trace(gc, ergo)("avg_survived: %f  avg_deviation: %f", _avg_survived->average(), _avg_survived->deviation());
+  log_debug(gc, ergo)("avg_survived_padded_avg: %f", _avg_survived->padded_average());
 
-    gclog_or_tty->print( "  avg_survived_padded_avg: %f",
-                _avg_survived->padded_average());
-
-    if (Verbose) {
-      gclog_or_tty->print( "  avg_promoted_avg: %f"
-                  "  avg_promoted_dev: %f",
-                  avg_promoted()->average(),
-                  avg_promoted()->deviation());
-    }
-
-    gclog_or_tty->print_cr( "  avg_promoted_padded_avg: %f"
-                "  avg_pretenured_padded_avg: %f"
-                "  tenuring_thresh: %d"
-                "  target_size: " SIZE_FORMAT,
-                avg_promoted()->padded_average(),
-                _avg_pretenured->padded_average(),
-                tenuring_threshold, target_size);
-  }
+  log_trace(gc, ergo)("avg_promoted_avg: %f  avg_promoted_dev: %f", avg_promoted()->average(), avg_promoted()->deviation());
+  log_debug(gc, ergo)("avg_promoted_padded_avg: %f  avg_pretenured_padded_avg: %f  tenuring_thresh: %d  target_size: " SIZE_FORMAT,
+                      avg_promoted()->padded_average(),
+                      _avg_pretenured->padded_average(),
+                      tenuring_threshold, target_size);
 
   set_survivor_size(target_size);
 
@@ -1233,24 +1117,22 @@
   }
   avg_promoted()->sample(promoted);
 
-  if (PrintAdaptiveSizePolicy) {
-    gclog_or_tty->print_cr(
-                  "AdaptiveSizePolicy::update_averages:"
-                  "  survived: "  SIZE_FORMAT
-                  "  promoted: "  SIZE_FORMAT
-                  "  overflow: %s",
-                  survived, promoted, is_survivor_overflow ? "true" : "false");
-  }
+  log_trace(gc, ergo)("AdaptiveSizePolicy::update_averages:  survived: "  SIZE_FORMAT "  promoted: "  SIZE_FORMAT "  overflow: %s",
+                      survived, promoted, is_survivor_overflow ? "true" : "false");
 }
 
-bool PSAdaptiveSizePolicy::print_adaptive_size_policy_on(outputStream* st)
-  const {
+bool PSAdaptiveSizePolicy::print() const {
 
-  if (!UseAdaptiveSizePolicy) return false;
+  if (!UseAdaptiveSizePolicy) {
+    return false;
+  }
 
-  return AdaptiveSizePolicy::print_adaptive_size_policy_on(
-                          st,
-                          PSScavenge::tenuring_threshold());
+  if (AdaptiveSizePolicy::print()) {
+    AdaptiveSizePolicy::print_tenuring_threshold(PSScavenge::tenuring_threshold());
+    return true;
+  }
+
+  return false;
 }
 
 #ifndef PRODUCT
--- a/src/share/vm/gc/parallel/psAdaptiveSizePolicy.hpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/psAdaptiveSizePolicy.hpp	Thu Dec 10 14:57:55 2015 +0100
@@ -395,7 +395,7 @@
                        size_t promoted);
 
   // Printing support
-  virtual bool print_adaptive_size_policy_on(outputStream* st) const;
+  virtual bool print() const;
 
   // Decay the supplemental growth additive.
   void decay_supplemental_growth(bool is_full_gc);
--- a/src/share/vm/gc/parallel/psCompactionManager.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/src/share/vm/gc/parallel/psCompactionManager.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -32,6 +32,7 @@
 #include "gc/parallel/psOldGen.hpp"
 #include "gc/parallel/psParallelCompact.inline.hpp"
 #include "gc/shared/taskqueue.inline.hpp"
+#include "logging/log.hpp"
 #include "memory/iterator.inline.hpp"
 #include "oops/instanceKlass.inline.hpp"
 #include "oops/instanceMirrorKlass.inline.hpp"
@@ -229,30 +230,18 @@
 static void oop_pc_follow_contents_specialized(InstanceRefKlass* klass, oop obj, ParCompactionManager* cm) {
   T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
   T heap_oop = oopDesc::load_heap_oop(referent_addr);
-  debug_only(
-    if(TraceReferenceGC && PrintGCDetails) {
-      gclog_or_tty->print_cr("InstanceRefKlass::oop_pc_follow_contents " PTR_FORMAT, p2i(obj));
-    }
-  )
+  log_develop_trace(gc, ref)("InstanceRefKlass::oop_pc_follow_contents " PTR_FORMAT, p2i(obj));
   if (!oopDesc::is_null(heap_oop)) {
     oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
     if (PSParallelCompact::mark_bitmap()->is_unmarked(referent) &&
         PSParallelCompact::ref_processor()->discover_reference(obj, klass->reference_type())) {
       // reference already enqueued, referent will be traversed later
       klass->InstanceKlass::oop_pc_follow_contents(obj, cm);
-      debug_only(
-        if(TraceReferenceGC && PrintGCDetails) {
-          gclog_or_tty->print_cr("       Non NULL enqueued " PTR_FORMAT, p2i(obj));
-        }
-      )
+      log_develop_trace(gc, ref)("       Non NULL enqueued " PTR_FORMAT, p2i(obj));
       return;
     } else {
       // treat referent as normal oop
-      debug_only(
-        if(TraceReferenceGC && PrintGCDetails) {
-          gclog_or_tty->print_cr("       Non NULL normal " PTR_FORMAT, p2i(obj));
-        }
-      )
+      log_develop_trace(gc, ref)("       Non NULL normal " PTR_FORMAT, p2i(obj));
       cm->mark_and_push(referent_addr);
     }
   }
@@ -262,12 +251,7 @@
   T  next_oop = oopDesc::load_heap_oop(next_addr);
   if (!oopDesc::is_null(next_oop)) { // i.e. ref is not "active"
     T* discovered_addr = (T*)java_lang_ref_Reference::discovered_addr(obj);
-    debug_only(
-      if(TraceReferenceGC && PrintGCDetails) {
-        gclog_or_tty->print_cr("   Pro