From: John Wolfe Date: Fri, 26 Mar 2021 03:21:17 +0000 (-0700) Subject: Implement log redirection for the deployPkg plugin. X-Git-Tag: stable-11.3.0~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5689130bbc010843b718a0691ee3765624beca00;p=thirdparty%2Fopen-vm-tools.git Implement log redirection for the deployPkg plugin. On Linux, /var/log/vmware-imc/toolsDeployPkg.log is the default deployPkgs log file. This change allows users to redirect that log to the vmware.log on the host or to another file located on the guest VM. Redirection is controlled by settings in the "logging" section of the tools.conf file. See the examples in the sample tools.conf file provided in the distribution. --- diff --git a/open-vm-tools/services/plugins/deployPkg/deployPkg.c b/open-vm-tools/services/plugins/deployPkg/deployPkg.c index 7805f59ee..76e49fc22 100644 --- a/open-vm-tools/services/plugins/deployPkg/deployPkg.c +++ b/open-vm-tools/services/plugins/deployPkg/deployPkg.c @@ -88,8 +88,39 @@ DeployPkgDeployPkgInGuest(ToolsAppCtx *ctx, // IN: app context int processTimeout; #endif - /* Init the logger */ - DeployPkgLog_Open(); + /* + * Init the logger + * PR 2109109. If the deployPkg log handler has been configured explicitly in + * tools.conf, then output deployPkg log through the specified handler. + * https://wiki.eng.vmware.com/Configuring_Logging_for_the_VMware_Tools + * If not, output the log to the default log file defined in + * function DeployPkgLog_Open. + * The deployPkg log handler is mainly configured for debugging purpose. + */ + char key[128]; + char *handler; + snprintf(key, sizeof key, "%s.handler", G_LOG_DOMAIN); + handler = VMTools_ConfigGetString(ctx->config, + CONFGROUPNAME_LOGGING, + key, + NULL); + if (handler != NULL && + (strcmp(handler, "vmx") == 0 || strcmp(handler, "file") == 0 || + strcmp(handler, "file+") == 0)) { + g_debug("Using deployPkg log handler: %s", handler); + free(handler); + } else { + DeployPkgLog_Open(); + + if (handler != NULL) { + DeployPkgLog_Log(log_debug, + "Log handler %s is not applicable for deployPkg," + " ignore it and ouput the log in GOS customization" + " default log path.", + handler); + free(handler); + } + } DeployPkg_SetLogger(DeployPkgLog_Log); DeployPkgLog_Log(log_debug, "Deploying %s", pkgFile); diff --git a/open-vm-tools/tools.conf b/open-vm-tools/tools.conf index 4fac64d09..4d55ebd37 100644 --- a/open-vm-tools/tools.conf +++ b/open-vm-tools/tools.conf @@ -124,6 +124,24 @@ #toolboxcmd.handler = file #toolboxcmd.data = c:/tmp/vmtoolboxcmd-${USER}.log +# With no explicit logging configuration for deployPkg, its default log path in +# Linux is /var/log/vmware-imc/toolsDeployPkg.log, and in Windows is +# %WINDIR%/Temp/vmware-imc/toolsDeployPkg.log +# Set the following configuration if you want to redirect the deployPkg log to +# any existing location other than the default. +#deployPkg.level = debug +#deployPkg.handler = file +#deployPkg.data = c:/tmp/toolsDeployPkg-${USER}.log + +# Redirecting the deployPkg log to the vmx log file. Please note that +# "log = true" and the vmsvc log handler setting to vmx are also neccessary +# if you want to redirect the deployPkg log to vmx. +#log = true +#vmsvc.level = debug +#vmsvc.handler = vmx +#deployPkg.level = debug +#deployPkg.handler = vmx + # Enable old VMwareUser/vmware-user logging to file. #log.file = c:/tmp/vmtools.log