Wednesday, November 6, 2013

Configure Logs for LVM in linux

 Log all LVM commands

[root@test ~]# cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf_backup
[root@test ~]# vi /etc/lvm/lvm.conf


log {

    # Controls the messages sent to stdout or stderr.
    # There are three levels of verbosity, 3 being the most verbose.
    verbose = 0

    # Should we send log messages through syslog?
    # 1 is yes; 0 is no.
    syslog = 1

    # Should we log error and debug messages to a file?
    # By default there is no log file.
    #file = "/var/log/lvm2.log"

    # Should we overwrite the log file each tisme the program is run?
    # By default we append.
    overwrite = 0

    # What level of log messages should we send to the log file and/or syslog?
    # There are 6 syslog-like log levels currently in use - 2 to 7 inclusive.
    # 7 is the most verbose (LOG_DEBUG).
    level = 0

   # Format of output messages
    # Whether or not (1 or 0) to indent messages according to their severity
    indent = 1

    # Whether or not (1 or 0) to display the command name on each line output
    command_names = 0

    # A prefix to use before the message text (but after the command name,
    # if selected).  Default is two spaces, so you can see/grep the severity
    # of each message.
    prefix = "  "

    # To make the messages look similar to the original LVM tools use:
    #   indent = 0
    #   command_names = 1
    #   prefix = " -- "

    # Set this if you want log messages during activation.
    # Don't use this in low memory situations (can deadlock).
    # activation = 0
}

2 modifications to be done

Uncomment the line # file = “/var/log/lvm2.log

Change the level = 0 to a value between 2 and 7.

What level of log messages should we send to the log file and/or syslog?

    # There are 6 syslog-like log levels currently in use - 2 to 7 inclusive.
    # 7 is the most verbose (LOG_DEBUG).

Enter level=7

save and exit.

Just test it with the lvm command and view the logs

This is not the right syntax, just showed here for example.

[root@test ~]# lvcreate VG1
  Please specify either size or extents
  Run `lvcreate --help' for more information.

[root@test ~]# tail -f /var/log/lvm2.log
activate/activate.c:471   Getting target version for striped
ioctl/libdm-iface.c:1687   dm versions   OF   [16384] (*1)
lvcreate.c:363   Please specify either size or extents
lvcreate.c:768   <backtrace>
lvmcmdline.c:623   Run `lvcreate --help' for more information.
lvmcmdline.c:1123   Completed: lvcreate VG1
cache/lvmcache.c:1602   Wiping internal VG cache
metadata/vg.c:74   Freeing VG #orphans_lvm1 at 0x1f09d90.
metadata/vg.c:74   Freeing VG #orphans_pool at 0x1f0e600.
metadata/vg.c:74   Freeing VG #orphans_lvm2 at 0x1f13110.



No comments: