VirtualBox

Changes between Initial Version and Version 1 of VBoxLogging


Ignore:
Timestamp:
Aug 22, 2011 11:51:38 AM (13 years ago)
Author:
Michael Thayer
Comment:

Public documentation for the iprt logging facility

Legend:

Unmodified
Added
Removed
Modified
  • VBoxLogging

    v1 v1  
     1= The VirtualBox/IPRT logging facility =
     2
     3The generic description of the IPRT logging facility is found [http://www.virtualbox.org/browser/trunk/src/VBox/Runtime/VBox/log-vbox.cpp#L27 here].
     4
     5IPRT log group names are found in source:trunk/include/iprt/log.h [[BR]]
     6!VirtualBox log group names are found in source:trunk/include/VBox/log.h
     7
     8!VirtualBox uses the env.vars `VBOX_LOG`, `VBOX_LOG_DEST` and `VBOX_LOG_FLAGS` to
     9control debug log output and `VBOX_RELEASE_LOG`, `VBOX_RELEASE_LOG_DEST` and
     10`VBOX_RELEASE_LOG_FLAGS` to control release log output.  Logging settings can also be
     11changed at runtime using the debugger.
     12
     13Examples:
     14
     15{{{
     16set VBOX_LOG=em=~0 rem* -rem_mmio
     17set VBOX_LOG_FLAGS=buffered thread tsc
     18}}}
     19
     20{{{
     21export VBOX_RELEASE_LOG="rem*.e.l.f main gui"
     22export VBOX_RELEASE_LOG_FLAGS="buffered thread msprog"
     23}}}
     24
     25{{{
     26export VBOX_LOG="dev_vmm"
     27export VBOX_LOG_FLAGS="msprog"
     28export VBOX_LOG_DEST="nofile stderr"
     29}}}
     30
     31The release logging even prints information to a destination when running a release
     32build of component/program. By default this destination is the release log file in the user's
     33!VirtualBox home directory, which is rotated on creation. To set the destination, use the
     34environment variable "VBOX_LOG_DEST" for debug logging and "VBOX_RELEASE_LOG_DEST" for
     35release logging, add the prefix "file=" (if logging to a file) or "dir=" (directory) plus
     36the file name / directory. See "Runtime\common\log\log.cpp" around line 300.
     37
     38By default, all level 1 release log statements ("!LogRel()") cause logging to the release log.
     39For level 2 ("LogRel2()"), flow logging ("!LogRelFlow()") etc to be written out, you need to
     40enable the logging types for the log groups you are interested in - e.g.
     41{{{
     42VBOX_RELEASE_LOG="+dev_vmm.e.l.f+main.e.l.f"
     43}}}
     44would enable the "dev_vmm" and "main" release log groups for level 2 and flow logging.
     45Release logging can be handy for debugging remote problems, but should of course be used
     46sparingly in performance-critical code.
     47
     48To enable ring-0 logging add VBOX_WITH_R0_LOGGING=1 to !LocalConfig.kmk or pass it to kmk in the command line (this part is not necessary for guest ring-0 logging) and set up loggging preferences in the source file src/VBox/Runtime/VBox/log-vbox.cpp.
     49
     50Some notes about group suffixes:[[BR]]
     51.eo (.enabledonly) - enabled only;[[BR]]
     52.e (.enabled) - enabled + level1;[[BR]]
     53.lX (.levelX) - level X , X 1-6 ;[[BR]]
     54.l = .l2;[[BR]]
     55.f (.flow);[[BR]]
     56
     57named suffixes:[[BR]]
     58Sometimes core developers use private logging statements which look like Log<Nick>(...), where <Nick> is the developer's nickname.  To enable those logging statements you must set the log flag for that developer.  For example, for the developer with the nick "NoName" (LogNoName(...) statements in the code) use the suffix[[BR]]
     59.n = .noname;[[BR]]
     60
     61To control where logging output/files go(es), use the VBOX_LOG_DEST variable, e.g.:
     62
     63{{{
     64export VBOX_LOG_DEST="dir=c:\temp"
     65}}}
     66
     67
     68To disable logging entirely, use one of:
     69
     70{{{
     71export VBOX_LOG_DEST=nofile
     72export VBOX_LOG_FLAGS=disabled
     73export VBOX_LOG=-all
     74}}}
     75
     76To enable Guest Additions logging, add to the host environment variables:
     77
     78{{{
     79set VBOX_LOG="-all+dev_vmm_backdoor.e.l.f+dev_vmm.e.l.f"
     80set VBOX_LOG_FLAGS="thread tsc"
     81}}}
     82
     83... and on the guest (for doing this in ring-0 bits see the section on ring-0 above):
     84
     85{{{
     86set VBOX_LOG="all"
     87}}}
     88
     89'''Note:''' You need to have the '''debug''' Guest Additions (that is, a debug version of VBoxGuest.<ext>) installed on the guest VM in order to make logging work with other guest components!
     90
     91'''Legacy warning:''' If "LOG_TO_BACKDOOR" is defined you might end up having cluttered logfiles if you use format specifiers (e.g. "%s") in your debug statements. Undefine / delete this define to use the "regular" IPRT way of logging things.
     92
     93For Shared Folders (Windows: VBoxSF.sys / VBOXMRXNP.dll)
     94
     95{{{
     96VBOX_LOG_FLAGS=thread
     97VBOX_LOG=+hgcm.e.f,+shared_folders.e.f
     98}}}
     99
     100Logging settings can be changed at runtime using a debugger.  Here are two examples with gdb:
     101
     102{{{
     103(gdb) call RTLogGroupSettings(0, "+drv_nat.e.l.f.l2.l3")
     104$1 = 0
     105}}}
     106
     107is the equivalent of passing the environment variable:
     108
     109{{{
     110VBOX_LOG=+drv_nat.e.l.f.l2.l3
     111}}}
     112
     113and
     114
     115{{{
     116(gdb) call RTLogRelDefaultInstance()
     117$1 = (RTLOGGER *) 0x2be2c30
     118(gdb) call RTLogFlags(0x2be2c30, "thread")
     119$2 = 0
     120}}}
     121
     122is the equivalent of:
     123
     124{{{
     125VBOX_RELEASE_LOG_FLAGS=thread
     126}}}

© 2023 Oracle
ContactPrivacy policyTerms of Use