Java 9 中的統一 JVM 日誌是什麼?
Java 9 可以為 JVM 元件提供一個具有詳細級別的通用日誌系統。透過使用新的命令列選項:**-Xlog** 用於所有**日誌設定**,並且**統一的 JVM 日誌**為我們提供了一個易於配置的工具來進行復雜系統級 JVM 元件的**根本原因分析 (RCA)**。
命令列**-Xlog** 可用於控制所有日誌記錄 JVM 元件。**-Xlog 的引數**遵循以下規則
- 多個引數按其在命令列中出現的順序應用。
- 最後的配置規則:對於相同的輸出,多個引數可以按給定的順序相互覆蓋。
**Xlog: disable** 關閉所有日誌記錄並清除日誌框架的所有配置(包括**警告**和**錯誤**)。
語法
-Xlog:tag[*][=level][:output:decoration:output-option],tag...
**-Xlog: help** 列印**-Xlog** 使用語法和可用的**標籤、級別、裝飾器**以及一些示例命令列。
1) 標籤:當顯示日誌訊息時,它與 JVM 中一組由名稱標識的標籤相關聯:os、gc、modules。我們為各個標籤應用不同的設定,並且“*”表示“萬用字元”標籤匹配。
2) 級別:我們在不同的級別執行日誌記錄,可用的級別為 error、warning、info、debug、trace 和 develop。要停用日誌記錄,然後使用替代選項 off。
3) 輸出:輸出支援三種類型:stdout、stderr 和文字檔案,以根據寫入大小和要輪換的檔案數量設定日誌檔案輪換。
4) 裝飾器:有關訊息的更多詳細資訊稱為裝飾器。以下是列表
- time/timemillis/timenanos:當前時間和日期(ISO-8601 格式)
- uptime/uptimemillis/uptimenanos:自 JVM 啟動以來的時間
- pid:程序識別符號
- tid:執行緒識別符號
- level:與日誌訊息關聯的級別
- tags:與日誌訊息關聯的標籤
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.)
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP