Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Java

Unified JVM Logging ใน Java 9 คืออะไร


Java 9 สามารถจัดเตรียมระบบการบันทึกทั่วไปสำหรับส่วนประกอบ JVM ที่มีระดับโดยละเอียด โดยใช้ตัวเลือกบรรทัดคำสั่งใหม่: -Xlog สำหรับ การตั้งค่าการบันทึก . ทั้งหมด และการบันทึก JVM แบบรวม ทำให้เรามีเครื่องมือที่กำหนดค่าได้ง่ายเพื่อทำ การวิเคราะห์สาเหตุ (RCA) ของส่วนประกอบ JVM ระดับระบบที่ซับซ้อน

บรรทัดคำสั่ง -Xlog สามารถใช้สำหรับควบคุมส่วนประกอบ JVM การบันทึกทั้งหมด ข้อโต้แย้งของ -Xlog ปฏิบัติตามกฎด้านล่าง:

  • มีการใช้อาร์กิวเมนต์หลายตัวในลำดับที่ปรากฏในบรรทัดคำสั่ง
  • กฎการกำหนดค่าล่าสุด:สำหรับเอาต์พุตเดียวกัน อาร์กิวเมนต์หลายตัวสามารถแทนที่กันในลำดับที่กำหนด

Xlog:ปิดการใช้งาน ปิดการบันทึกทั้งหมดและล้างการกำหนดค่าทั้งหมดของเฟรมเวิร์กการบันทึก (รวมถึง คำเตือน และ ข้อผิดพลาด )

ไวยากรณ์

-Xlog:tag[*][=level][:output:decoration:output-option],tag...

-Xlog:ช่วย พิมพ์ -Xlog ไวยากรณ์การใช้งานและ แท็ก ระดับ มัณฑนากร พร้อมกับตัวอย่างบรรทัดคำสั่ง

1) แท็ก :เมื่อข้อความบันทึกปรากฏขึ้น จะเชื่อมโยงกับชุดแท็กใน JVM ที่ระบุชื่อ:os, gc, โมดูล เราใช้การตั้งค่าที่แตกต่างกันสำหรับแต่ละแท็ก และ '*' หมายถึงการจับคู่แท็ก 'wildcard'

2) ระดับ :เราทำการบันทึกในระดับต่างๆ และระดับที่มีคือข้อผิดพลาด คำเตือน ข้อมูล ดีบัก ติดตามและพัฒนา หากต้องการปิดใช้งานการบันทึก ให้ใช้ทางเลือกอื่นปิด

3) ผลลัพธ์ :เอาต์พุตรองรับสามประเภท:stdout, stderr และไฟล์ข้อความเพื่อตั้งค่าการหมุนไฟล์บันทึกตามขนาดที่เขียนและจำนวนไฟล์ที่จะหมุน

4) นักตกแต่ง :มีรายละเอียดเพิ่มเติมเกี่ยวกับข้อความที่เรียกว่ามัณฑนากร นี่คือรายการ:

  • เวลา/timemillis/timenanos :เวลาและวันที่ปัจจุบัน (รูปแบบ ISO-8601)
  • uptime/uptimemillis/uptimenanos :เวลาตั้งแต่เริ่มต้น JVM
  • พิด :ตัวระบุกระบวนการ
  • ทีเด็ด :ตัวระบุเธรด
  • ระดับ :ระดับที่เกี่ยวข้องกับข้อความบันทึก
  • แท็ก :แท็กที่เกี่ยวข้องกับข้อความบันทึก


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.)