O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

Let's run some of the log settings, which are as follows:

  1. Run the following command:
      java -Xlog:cpu -cp ./cookbook-1.0.jar      com.packt.cookbook.ch12_memory.Chapter12Memory

There are no messages because the JVM does not log messages with the cpu tag only. The tag is used in combination with other tags.

  1. Add a * sign and run the command again:
      java -Xlog:cpu* -cp ./cookbook-1.0.jar      com.packt.cookbook.ch12_memory.Chapter12Memory

The result will look as follows:

As you can see, the tag cpu brings only messages that log time it took a garbage collection task to execute. Even if we set the log level to trace or debug (-Xlog:cpu*=debug ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required