- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is Unified JVM Logging in Java 9?
85 Lectures 6 hours
Java 9 can provide a common logging system for JVM components with a detailed level. By using a new command-line option: -Xlog for all logging settings and unified JVM logging gives us an easy-to-configure tool to do a root cause analysis (RCA) of complex system-level JVM components.
The command line -Xlog can be used for controlling all logging JVM components. The arguments of -Xlog follow the below rules:
- Multiple arguments have applied in the order they appear in the command-line.
- Last configuration rules: for the same output, multiple arguments can override each other in the given order.
Xlog: disable turns off all logging and clears all configuration of the logging framework (including warnings and errors).
-Xlog: help prints -Xlog usage syntax and available tags, levels, decorators along with some example command lines.
1) Tags: When a log message has shown, it is associated with a set of tags in the JVM that identify by names: os, gc, modules. We apply different settings for individual tags and ‘*’ denotes a ‘wildcard’ tag match.
2) Levels: We perform logging at different levels, and available levels are error, warning, info, debug, trace and develop. To disable logging, then use alternative off.
3) Outputs: The output supports three types: stdout, stderr, and text file to set up for log file rotation based on written size and a number of files to rotate.
4) Decorators: There are more details about the message called decorators. Here is the list:
- time/timemillis/timenanos: current time and date (ISO-8601 format)
- uptime/uptimemillis/uptimenanos: time since the start of the JVM
- pid: process identifier
- tid: thread identifier
- level: level associated with the log message
- tags: tag associated with the log message
C:\Program Files\Java\jdk-9.0.4\bin>java -Xlog:help -Xlog Usage: -Xlog[:[what][:[output][:[decorators][:output-options]]]] where 'what' is a combination of tags and levels of the form tag1[+tag2...][*][=level][,...] Unless wildcard (*) is specified, only log messages tagged with exactly the tags specified will be matched. Available log levels: off, trace, debug, info, warning, error Available log decorators: time (t), utctime (utc), uptime (u), timemillis (tm), uptimemillis (um), timenanos (tn), uptimenanos (un), hostname(hn), pid (p), tid (ti), level (l), tags (tg) Decorators can also be specified as 'none' for no decoration. Available log tags: add, age, alloc, aot, annotation, arguments, attach, barrier, biasedlocking, blocks, bot, breakpoint, census, class, classhisto, cleanup, compaction, constraints, constantpool, coops, cpu, cset, data, defaultmethods, dump, ergo, exceptions, exit, fingerprint, freelist, gc, hashtables, heap, humongous, ihop, iklass, in it, itables, jni, jvmti,liveness, load, loader, logging, mark, marking, methodcomparator, metadata, metaspace, mmu, module, monitorinflation,monitormismatch, nmethod, normalize, objecttagging, obsolete, oopmap, os, pagesize, patch, path, phases, plab, promotion,preorder, protectiondomain, ref, redefine, refine, region, remset, purge, resolve, safepoint, scavenge, scrub, stacktrace,stackwalk, start, startuptime, state, stats, stringdedup, stringtable, stackmap, subclass, survivor, sweep, task, thread,tlab, time, timer, update, nload, verification, verify, vmoperation, vtables, workgang, jfr, system, parser, bytecode,setting, event Specifying 'all' instead of a tag combination matches all tag combinations. Described tag combinations: logging: Logging for the log framework itself Available log outputs: stdout, stderr, file= Specifying %p and/or %t in the filename will expand to the JVM's PID and startup timestamp, respectively. Some examples: -Xlog Log all messages using 'info' level to stdout with 'uptime', 'levels' and 'tags' decorations. (Equivalent to -Xlog:all=info:stdout:uptime,levels,tags). -Xlog:gc Log messages tagged with 'gc' tag using 'info' level to stdout, with default decorations. -Xlog:gc,safepoint Log messages tagged either with 'gc' or 'safepoint' tags, both using 'info' level, to stdout, with default decorations. (Messaged tagged with both 'gc' and 'safepoint' will not be logged.)
- What is Platform Logging API in Java 9?
- What is Java Virtual Machine (JVM)?
- What is JVM, Java virtual machine?
- What is Module System in Java 9?
- What is Project Jigsaw in Java 9?
- What is Variable Handle in Java 9?
- Verification in Java (JVM)
- What is the JLink tool in Java 9?
- What is New Versioning Scheme in Java 9?
- What is Http/2 Client in Java 9?
- What is an unnamed module in Java 9?
- Java (JVM) Memory Types
- Java (JVM) memory model
- JVM shutdown hook in Java
- What are Java JVM Run-time Data Areas?