HowTos : How to log all LVM commands

By default, the LVM configuration does not allow you to log the commands that are used in a shell or in a GUI (e.g system-config-lvm) environment. However, it’s possible to active logging using the configuration file /etc/lvm/lvm.conf.

Activate logging for all LVM commands

To active logging follow these steps.
1. Edit the lvm.conf file and find the log section. The default configuration looks like the following:

# vi /etc/lvm/lvm.conf
log {
     verbose = 0 
     syslog = 1 
     #file = "/var/log/lvm2.log"
     overwrite = 0 
     level = 0 
     indent = 1 
     command_names = 0 
     prefix = "  "
     # activation = 0
}

NOTE: It is possible for lvm to log messages directly to a separate file ( by uncommenting the #file = “/var/log/lvm2.log” option). However, using syslog has two advantages.
a. The /var/log/messages file is automatically handled by logrotate, whereas a new lvm2.log file would require new logrotate configuration to ensure it does not grow uncontrollably.
b. Messages directed to /var/log/messages will automatically be prepended with a timestamp. Using a separate file will not include timestamps by default. Timestamps are useful for correlating messages with other known events when troubleshooting.

2. Change the level = 0 to a value between 2 and 7.
level 0 – produces no output.
level 7 – is the most verbose output.

3. Save the changes and exit. It’s not necessary to restart any service. Log messages will start being produced as soon as an lvm command is executed. Log messages will be saved in /var/log/messages.

Disabling LVM logging

Enabling LVM commands logging may flood your /var/log/messages file. You can disable lvm debug logging in /etc/lvm/lvm.conf i.e. use “level = 0”. For Example:

ronserver# vi /etc/lvm/lvm.conf
log {
     verbose = 0 
     syslog = 1 
     #file = "/var/log/lvm2.log"
     overwrite = 0 
     level = 0          ### disabled LVM verbose logging
     indent = 1 
     command_names = 0 
     prefix = "  "
     # activation = 0
}

Ron Jagannathan has written 54 articles

Ronan is a Caffeine dependent life-form from Planet Earth who wants to be a Jedi Knight of cloud computing. A man of mystery and power, whose power is exceeded only by his mystery. Quantum Physicist, TransHumanist, Systems Architect, Unix Administrator, Artificial Intelligence, Machine Learning and DIY Gadget enthusiast. Believes that the Universe has a high probability of being a simulation.
But he's real and hopefully some of his readers are too.
email: Ron.Jagannathan@gmail.com ph: 202 355 5205
https://www.linkedin.com/in/ronjagan/
My Famous Quotes:
“In a Unix Universe, God is known by a four letter word called root. To err is human...to really foul requires you to be root.. err.. god.” ― Ron Jagannathan

Github: github.com/ronjag
Linkedin: linkedin.com/in/ronjagan/

“Quotes found on the Internet are not always accurate.” ― Abraham Lincoln

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>