最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

淺談JDK9的特性之JVM的xlog

 更新時(shí)間:2021年06月02日 10:36:23   作者:flydean  
在java程序中,我們通過日志來定位和發(fā)現(xiàn)項(xiàng)目中可能出現(xiàn)的問題。在現(xiàn)代java項(xiàng)目中,我們使用log4j或者slf4j,Logback等日志記錄框架來處理日志問題。本文將介紹JDK9的特性之JVM的xlog。

簡介

JVM是java程序運(yùn)行的基礎(chǔ),JVM中各種事件比如:GC,class loading,JPMS,heap,thread等等其實(shí)都可以有日志來記錄。通過這些日志,我們可以監(jiān)控JVM中的事件,并可以依次來對java應(yīng)用程序進(jìn)行調(diào)優(yōu)。

在JDK9中引入的Xlog日志服務(wù)就是為這個(gè)目的而創(chuàng)建的。

通過xlog,JDK將JVM中的各種事件統(tǒng)一起來,以統(tǒng)一的形式對外輸出。通過tag參數(shù)來區(qū)分子系統(tǒng),通過log level來區(qū)分事件的緊急性,通過logging output來配置輸出的地址。

xlog的使用

先看一個(gè)最簡單的xlog的使用例子:

java -Xlog -version

輸出結(jié)果:

[0.016s][info][os] Use of CLOCK_MONOTONIC is supported

[0.016s][info][os] Use of pthread_condattr_setclock is not supported

[0.016s][info][os] Relative timed-wait using pthread_cond_timedwait is associated with the default clock

[0.017s][info][os] SafePoint Polling address, bad (protected) page:0x0000000108901000, good (unprotected) page:0x0000000108902000

[0.022s][info][biasedlocking] Aligned thread 0x00007f983e008200 to 0x00007f983e008800

[0.023s][info][os,thread    ] Thread attached (tid: 10499, pthread id: 123145571979264).

日志非常非常長,這里就不全部列出來了。從輸出的日志我們可以看到j(luò)ava -verson命令中JVM執(zhí)行了諸多的操作。

我們可以看到日志中對每一個(gè)操作都列出了操作花費(fèi)的時(shí)間,日志級別和操作所屬的分類。

通過這些日志,我們對于JVM的運(yùn)行可以有更加深入的理解。

使用java -Xlog:help命令我們看一下xlog的基本格式:

-Xlog Usage: -Xlog[:[selections][:[output][:[decorators][:output-options]]]]

where 'selections' are combinations of tags and levels of the form tag1[+tag2...][*][=level][,...]

NOTE: Unless wildcard (*) is specified, only log messages tagged with exactly the tags specified will be matched.

selections

selections表示的是到底需要輸出哪些信息。是以tag=level來表示的。

tag表示的是JVM中的事件或者子系統(tǒng):

Available log tags:

 add, age, alloc, annotation, aot, arguments, attach, barrier, biasedlocking, blocks, bot, breakpoint, bytecode, cds, census, class, classhisto, cleanup, codecache, compaction, compilation, constantpool, constraints, container, coops, cpu, cset, data, datacreation, dcmd, decoder, defaultmethods, director, dump, dynamic, ergo, event, exceptions, exit, fingerprint, free, freelist, gc, handshake, hashtables, heap, humongous, ihop, iklass, init, inlining, install, interpreter, itables, jfr, jit, jni, jvmti, liveness, load, loader, logging, malloc, mark, marking, membername, memops, metadata, metaspace, methodcomparator, mirror, mmu, module, monitorinflation, monitormismatch, nestmates, nmethod, normalize, numa, objecttagging, obsolete, oldobject, oom, oopmap, oops, oopstorage, os, pagesize, parser, patch, path, perf, periodic, phases, plab, preorder, preview, promotion, protectiondomain, ptrqueue, purge, record, redefine, ref, refine, region, reloc, remset, resolve, safepoint, sampling, scavenge, setting, smr, stackmap, stacktrace, stackwalk, start, startuptime, state, stats, streaming, stringdedup, stringtable, subclass, survivor, sweep, symboltable, system, table, task, thread, time, timer, tlab, tracking, unload, unshareable, update, verification, verify, vmmutex, vmoperation, vmthread, vtables, vtablestubs, workgang

 Specifying 'all' instead of a tag combination matches all tag combinations

levels表示的是日志的級別:

Available log levels: off, trace, debug, info, warning, error

下面舉個(gè)例子:

java -Xlog:os,class=info -version

輸出結(jié)果:

[0.002s][info][os] Use of CLOCK_MONOTONIC is supported

[0.002s][info][os] Use of pthread_condattr_setclock is not supported

[0.002s][info][os] Relative timed-wait using pthread_cond_timedwait is associated with the default clock

[0.003s][info][os] SafePoint Polling address, bad (protected) page:0x0000000109543000, good (unprotected) page:0x0000000109544000

[0.006s][info][os] attempting shared library load of /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/lib/libjava.dylib

[0.007s][info][os] shared library load of /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/lib/libjava.dylib was successful

[0.007s][info][os] attempting shared library load of /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/lib/libzip.dylib

[0.010s][info][os] shared library load of /Library/Java/JavaVirtualMachines/jdk-14.0.1.jdk/Contents/Home/lib/libzip.dylib was successful

output

output表示將日志輸出到什么地方。

output的可選項(xiàng):

stdout/stderr file=<filename>

stdout表示標(biāo)準(zhǔn)輸出,stderr表示標(biāo)準(zhǔn)錯(cuò)誤。file表示輸出到文件里面。

舉個(gè)例子:

java -Xlog:all=debug:file=debug.log -version

decorators

decorators表示輸出哪些內(nèi)容到日志中。

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

看下這個(gè)例子:

 java -Xlog:gc*=debug:stdout:time,uptimemillis,tid -version

輸出結(jié)果:

[2020-05-05T16:12:06.871-0800][32ms][9475] Heap region size: 1M

[2020-05-05T16:12:06.871-0800][32ms][9475] Minimum heap 8388608  Initial heap 134217728  Maximum heap 2147483648

[2020-05-05T16:12:06.872-0800][33ms][9475] Heap address: 0x0000000780000000, size: 2048 MB, Compressed Oops mode: Zero based, Oop shift amount: 3

[2020-05-05T16:12:06.872-0800][33ms][9475] ConcGCThreads: 1 offset 8

[2020-05-05T16:12:06.872-0800][33ms][9475] ParallelGCThreads: 4

以上就是淺談JDK9的特性之JVM的xlog的詳細(xì)內(nèi)容,更多關(guān)于JDK9的特性之JVM的xlog的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Java方法及數(shù)組相關(guān)原理解析

    Java方法及數(shù)組相關(guān)原理解析

    這篇文章主要介紹了Java方法及數(shù)組相關(guān)原理解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-12-12
  • SpringCloud Nacos作為配置中心超詳細(xì)講解

    SpringCloud Nacos作為配置中心超詳細(xì)講解

    這篇文章主要介紹了Springcloud中的Nacos作為配置中心,本文以用戶微服務(wù)為例,進(jìn)行統(tǒng)一的配置,結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2022-12-12
  • Java中的FileInputStream是否需要close問題

    Java中的FileInputStream是否需要close問題

    這篇文章主要介紹了Java中的FileInputStream是否需要close問題,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • Springmvc ajax跨域請求處理方法實(shí)例詳解

    Springmvc ajax跨域請求處理方法實(shí)例詳解

    這篇文章主要介紹了Springmvc ajax跨域請求處理方法實(shí)例詳解,需要的朋友可以參考下
    2017-10-10
  • SpringBoot結(jié)合Quartz實(shí)現(xiàn)數(shù)據(jù)庫存儲(chǔ)

    SpringBoot結(jié)合Quartz實(shí)現(xiàn)數(shù)據(jù)庫存儲(chǔ)

    本文主要介紹了SpringBoot+Quartz+數(shù)據(jù)庫存儲(chǔ),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • Java對象轉(zhuǎn)JSON時(shí)動(dòng)態(tài)的增刪改查屬性詳解

    Java對象轉(zhuǎn)JSON時(shí)動(dòng)態(tài)的增刪改查屬性詳解

    這篇文章主要介紹了Java對象轉(zhuǎn)JSON時(shí)如何動(dòng)態(tài)的增刪改查屬性的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • SpringBoot處理JSON數(shù)據(jù)方法詳解

    SpringBoot處理JSON數(shù)據(jù)方法詳解

    這篇文章主要介紹了SpringBoot整合Web開發(fā)中Json數(shù)據(jù)處理,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-10-10
  • 教你在一分鐘之內(nèi)理解Java Lambda表達(dá)式并學(xué)會(huì)使用

    教你在一分鐘之內(nèi)理解Java Lambda表達(dá)式并學(xué)會(huì)使用

    今天給大家?guī)У奈恼率荍ava8新特性的相關(guān)知識,文章圍繞著如何在一分鐘之內(nèi)理解Java Lambda表達(dá)式并學(xué)會(huì)使用展開,文中有非常詳細(xì)的介紹,需要的朋友可以參考下
    2021-06-06
  • springboot無法跳轉(zhuǎn)頁面的問題解決方案

    springboot無法跳轉(zhuǎn)頁面的問題解決方案

    這篇文章主要介紹了springboot無法跳轉(zhuǎn)頁面的問題解決方案,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-09-09
  • Mybatis實(shí)現(xiàn)動(dòng)態(tài)排序方式

    Mybatis實(shí)現(xiàn)動(dòng)態(tài)排序方式

    這篇文章主要介紹了Mybatis實(shí)現(xiàn)動(dòng)態(tài)排序方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-10-10

最新評論

盈江县| 湘潭市| 荣成市| 江达县| 高州市| 通榆县| 颍上县| 宁阳县| 佛冈县| 刚察县| 兴城市| 舒城县| 平舆县| 海原县| 冀州市| 新建县| 德阳市| 龙里县| 琼中| 绵阳市| 津南区| 海兴县| 蓬莱市| 唐河县| 鹤山市| 新宁县| 瓦房店市| 邹城市| 谢通门县| 西盟| 临桂县| 柳河县| 二连浩特市| 宜宾县| 永和县| 云安县| 墨江| 东乌珠穆沁旗| 新密市| 团风县| 神农架林区|