6

When I run vagrant up using VirtualBox as a provider, it creates a logfile called ubuntu-xenial-16.04-cloudimg-console.log in the project root. This causes difficulty with PHPStorm, as it doesn't have an option to exclude individual files from search, only folders.

I would like to have this logfile created in the _log directory instead, but I cannot find how to configure its location; there doesn't seem to be anything in the Vagrantfile documentation, and I can't find an option in the VirtualBox GUI.

I've also tried symlinking the file to /dev/null, but VirtualBox refuses to even start if the link is there. I can't simply delete the file while the VM is up, as it holds a lock on it.

A simplified version of the Vagrantfile is below:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"

  config.disksize.size = "10GB"

  config.vm.network "forwarded_port", guest: 80, host: 80, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 3306, host: 3306, host_ip: "127.0.0.1"

  config.vm.synced_folder ".", "/var/www/html"

  config.vm.provider "virtualbox" do |vb|
    vb.gui = false
    vb.memory = "2048"
  end

  config.vm.provision "shell", inline: <<-SHELL
    # redacted
  SHELL
end

How can I change the log location? Or, if that's possible, how can I prevent it from being generated in the first place?

10

I managed to change the log file location as per this post. To change the log file location to a folder called /temp relative to my Vagrantfile, I added this to the Vagrantfile (inside the Vagrant.configure(2) do |config| - section):

config.vm.provider "virtualbox" do |vb|
  vb.customize [
    "modifyvm", :id, "--uartmode1", "file",
    File.join(Dir.pwd, "temp/ubuntu-xenial-16.04-cloudimg-console.log")
  ]
end

This seems to override the current location settings. The temp-folder must already be present.

To completely disable the log file output, follow the recipe from the above link:

config.vm.provider "virtualbox" do |vb|
  vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
end
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.