diff --git a/user_channel/channel_layer.cpp b/user_channel/channel_layer.cpp
index 85c3426..02dd055 100644
--- a/user_channel/channel_layer.cpp
+++ b/user_channel/channel_layer.cpp
@@ -19,7 +19,7 @@
 #include "channel_mgmt.hpp"
 #include "cipher_mgmt.hpp"
 
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 namespace ipmi
 {
@@ -34,8 +34,7 @@
 
     if (stat(devName.data(), &fileStat) != 0)
     {
-        phosphor::logging::log<phosphor::logging::level::DEBUG>(
-            "Ethernet device not found");
+        lg2::debug("Ethernet device not found");
         return false;
     }
 
diff --git a/user_channel/channel_mgmt.cpp b/user_channel/channel_mgmt.cpp
index 841cce5..13ea55b 100644
--- a/user_channel/channel_mgmt.cpp
+++ b/user_channel/channel_mgmt.cpp
@@ -39,8 +39,6 @@
 namespace ipmi
 {
 
-using namespace phosphor::logging;
-
 static constexpr const char* channelAccessDefaultFilename =
     "/usr/share/ipmi-providers/channel_access.json";
 static constexpr const char* channelConfigDefaultFilename =
diff --git a/user_channel/channelcommands.cpp b/user_channel/channelcommands.cpp
index cd0a33b..321526f 100644
--- a/user_channel/channelcommands.cpp
+++ b/user_channel/channelcommands.cpp
@@ -18,12 +18,10 @@
 #include "channel_layer.hpp"
 
 #include <ipmid/api.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <regex>
 
-using namespace phosphor::logging;
-
 namespace ipmi
 {
 
@@ -51,7 +49,7 @@
     if (reserved1 || reserved2 ||
         !isValidPrivLimit(static_cast<uint8_t>(channelPrivLimit)))
     {
-        log<level::DEBUG>("Set channel access - Invalid field in request");
+        lg2::debug("Set channel access - Invalid field in request");
         return responseInvalidFieldRequest();
     }
 
@@ -60,7 +58,8 @@
     if ((getChannelSessionSupport(chNum) == EChannelSessSupported::none) ||
         (!isValidChannel(chNum)))
     {
-        log<level::DEBUG>("Set channel access - No support on channel");
+        lg2::debug("Set channel access - No support on channel: {CHANNEL}",
+                   "CHANNEL", chNum);
         return response(ccActionNotSupportedForChannel);
     }
 
@@ -96,7 +95,7 @@
 
         case reserved:
         default:
-            log<level::DEBUG>("Set channel access - Invalid access set mode");
+            lg2::debug("Set channel access - Invalid access set mode");
             return response(ccAccessModeNotSupportedForChannel);
     }
 
@@ -117,7 +116,7 @@
             break;
         case reserved:
         default:
-            log<level::DEBUG>("Set channel access - Invalid access priv mode");
+            lg2::debug("Set channel access - Invalid access priv mode");
             return response(ccAccessModeNotSupportedForChannel);
     }
 
@@ -126,7 +125,7 @@
         compCode = setChannelAccessPersistData(chNum, chNVData, setNVFlag);
         if (compCode != ccSuccess)
         {
-            log<level::DEBUG>("Set channel access - Failed to set access data");
+            lg2::debug("Set channel access - Failed to set access data");
             return response(compCode);
         }
     }
@@ -136,7 +135,7 @@
         compCode = setChannelAccessData(chNum, chActData, setActFlag);
         if (compCode != ccSuccess)
         {
-            log<level::DEBUG>("Set channel access - Failed to set access data");
+            lg2::debug("Set channel access - Failed to set access data");
             return response(compCode);
         }
     }
@@ -174,14 +173,14 @@
 {
     if (reserved1 || reserved2)
     {
-        log<level::DEBUG>("Get channel access - Invalid field in request");
+        lg2::debug("Get channel access - Invalid field in request");
         return responseInvalidFieldRequest();
     }
 
     if ((types::enum_cast<EChannelActionType>(accessSetMode) == doNotSet) ||
         (types::enum_cast<EChannelActionType>(accessSetMode) == reserved))
     {
-        log<level::DEBUG>("Get channel access - Invalid Access mode");
+        lg2::debug("Get channel access - Invalid Access mode");
         return responseInvalidFieldRequest();
     }
 
@@ -191,7 +190,8 @@
     if ((getChannelSessionSupport(chNum) == EChannelSessSupported::none) ||
         (!isValidChannel(chNum)))
     {
-        log<level::DEBUG>("Get channel access - No support on channel");
+        lg2::debug("Get channel access - No support on channel: {CHANNEL}",
+                   "CHANNEL", chNum);
         return response(ccActionNotSupportedForChannel);
     }
 
@@ -252,7 +252,7 @@
 {
     if (reserved)
     {
-        log<level::DEBUG>("Get channel access - Invalid field in request");
+        lg2::debug("Get channel access - Invalid field in request");
         return responseInvalidFieldRequest();
     }
 
@@ -260,7 +260,8 @@
                                              ctx->channel);
     if (!isValidChannel(chNum))
     {
-        log<level::DEBUG>("Get channel Info - No support on channel");
+        lg2::debug("Get channel Info - No support on channel: {CHANNEL}",
+                   "CHANNEL", chNum);
         return responseInvalidFieldRequest();
     }
 
@@ -268,9 +269,9 @@
     Cc compCode = getChannelInfo(chNum, chInfo);
     if (compCode != ccSuccess)
     {
-        log<level::ERR>("Failed to get channel info",
-                        entry("CHANNEL=%x", chNum),
-                        entry("ERRNO=%x", compCode));
+        lg2::error("Failed to get channel info, channel: {CHANNEL}, "
+                   "errno: {ERRNO}",
+                   "CHANNEL", chNum, "ERRNO", compCode);
         return response(compCode);
     }
 
@@ -329,14 +330,14 @@
 
     if (!doesDeviceExist(chNum) || !isValidChannel(chNum) || reserved)
     {
-        log<level::DEBUG>("Get channel payload - Invalid field in request");
+        lg2::debug("Get channel payload - Invalid field in request");
         return responseInvalidFieldRequest();
     }
 
     // Session support is available in active LAN channels.
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
-        log<level::DEBUG>("Get channel payload - No support on channel");
+        lg2::debug("Get channel payload - No support on channel");
         return response(ccActionNotSupportedForChannel);
     }
     constexpr uint16_t stdPayloadType = standardPayloadBit(PayloadType::IPMI) |
@@ -374,22 +375,19 @@
 
     if (reserved || !isValidChannel(channel))
     {
-        log<level::DEBUG>(
-            "Get channel payload version - Invalid field in request");
+        lg2::debug("Get channel payload version - Invalid field in request");
         return responseInvalidFieldRequest();
     }
 
     if (getChannelSessionSupport(channel) == EChannelSessSupported::none)
     {
-        log<level::DEBUG>(
-            "Get channel payload version - No support on channel");
+        lg2::debug("Get channel payload version - No support on channel");
         return response(payloadTypeNotSupported);
     }
 
     if (!isValidPayloadType(static_cast<PayloadType>(payloadTypeNum)))
     {
-        log<level::ERR>(
-            "Get channel payload version - Payload type unavailable");
+        lg2::error("Get channel payload version - Payload type unavailable");
 
         return response(payloadTypeNotSupported);
     }
diff --git a/user_channel/cipher_mgmt.cpp b/user_channel/cipher_mgmt.cpp
index a2f024b..f1bc543 100644
--- a/user_channel/cipher_mgmt.cpp
+++ b/user_channel/cipher_mgmt.cpp
@@ -20,7 +20,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <filesystem>
 #include <fstream>
@@ -28,7 +28,6 @@
 namespace ipmi
 {
 
-using namespace phosphor::logging;
 using Json = nlohmann::json;
 namespace fs = std::filesystem;
 
@@ -51,7 +50,7 @@
 {
     if (!fs::exists(cipherSuiteDefaultPrivFileName))
     {
-        log<level::ERR>("CS privilege levels default file does not exist...");
+        lg2::error("CS privilege levels default file does not exist...");
     }
     else
     {
@@ -98,7 +97,7 @@
     std::ifstream jsonFile(csFileName);
     if (!jsonFile.good())
     {
-        log<level::ERR>("JSON file not found");
+        lg2::error("JSON file not found");
         return nullptr;
     }
 
@@ -109,8 +108,9 @@
     }
     catch (const Json::parse_error& e)
     {
-        log<level::ERR>("Corrupted cipher suite privilege levels config file.",
-                        entry("MSG: %s", e.what()));
+        lg2::error(
+            "Corrupted cipher suite privilege levels config file: {ERROR}",
+            "ERROR", e);
     }
 
     return data;
@@ -129,8 +129,8 @@
 
     if (fd < 0)
     {
-        log<level::ERR>("Error opening CS privilege level config file",
-                        entry("FILE_NAME=%s", tmpFile.c_str()));
+        lg2::error("Error opening CS privilege level config file: {FILE_NAME}",
+                   "FILE_NAME", tmpFile);
         return -EIO;
     }
     const auto& writeData = jsonData.dump();
@@ -138,8 +138,8 @@
         static_cast<ssize_t>(writeData.size()))
     {
         close(fd);
-        log<level::ERR>("Error writing CS privilege level config file",
-                        entry("FILE_NAME=%s", tmpFile.c_str()));
+        lg2::error("Error writing CS privilege level config file: {FILE_NAME}",
+                   "FILE_NAME", tmpFile);
         unlink(tmpRandomFile.data());
         return -EIO;
     }
@@ -147,8 +147,8 @@
 
     if (std::rename(tmpRandomFile.data(), cipherSuitePrivFileName.c_str()))
     {
-        log<level::ERR>("Error renaming CS privilege level config file",
-                        entry("FILE_NAME=%s", tmpFile.c_str()));
+        lg2::error("Error renaming CS privilege level config file: {FILE_NAME}",
+                   "FILE_NAME", tmpFile);
         unlink(tmpRandomFile.data());
         return -EIO;
     }
@@ -161,8 +161,7 @@
     auto iter = std::find(ipmi::privList.begin(), ipmi::privList.end(), value);
     if (iter == privList.end())
     {
-        log<level::ERR>("Invalid privilege.",
-                        entry("PRIV_STR=%s", value.c_str()));
+        lg2::error("Invalid privilege: {PRIV_STR}", "PRIV_STR", value);
         return ccUnspecifiedError;
     }
 
@@ -179,7 +178,7 @@
 {
     if (!isValidChannel(chNum))
     {
-        log<level::ERR>("Invalid channel number", entry("CHANNEL=%u", chNum));
+        lg2::error("Invalid channel number: {CHANNEL}", "CHANNEL", chNum);
         return ccInvalidFieldRequest;
     }
 
@@ -195,15 +194,15 @@
 {
     if (!isValidChannel(chNum))
     {
-        log<level::ERR>("Invalid channel number", entry("CHANNEL=%u", chNum));
+        lg2::error("Invalid channel number: {CHANNEL}", "CHANNEL", chNum);
         return ccInvalidFieldRequest;
     }
 
     Json jsonData;
     if (!fs::exists(cipherSuitePrivFileName))
     {
-        log<level::INFO>("CS privilege levels user settings file does not "
-                         "exist. Creating...");
+        lg2::info("CS privilege levels user settings file does not "
+                  "exist. Creating...");
     }
     else
     {
@@ -234,7 +233,7 @@
 
     if (writeCSPrivilegeLevels(jsonData))
     {
-        log<level::ERR>("Error in setting CS Privilege Levels.");
+        lg2::error("Error in setting CS Privilege Levels.");
         return ccUnspecifiedError;
     }
 
diff --git a/user_channel/passwd_mgr.cpp b/user_channel/passwd_mgr.cpp
index acf7c74..9b35ac7 100644
--- a/user_channel/passwd_mgr.cpp
+++ b/user_channel/passwd_mgr.cpp
@@ -26,7 +26,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <cerrno>
 #include <cstring>
@@ -59,8 +59,6 @@
     size_t macSize;
 };
 
-using namespace phosphor::logging;
-
 PasswdMgr::PasswdMgr()
 {
     restrictFilesPermission();
@@ -77,7 +75,7 @@
         {
             if (chmod(passwdFileName, S_IRUSR | S_IWUSR) == -1)
             {
-                log<level::DEBUG>("Error setting chmod for ipmi_pass file");
+                lg2::debug("Error setting chmod for ipmi_pass file");
             }
         }
     }
@@ -88,7 +86,7 @@
         {
             if (chmod(encryptKeyFileName, S_IRUSR | S_IWUSR) == -1)
             {
-                log<level::DEBUG>("Error setting chmod for ipmi_pass file");
+                lg2::debug("Error setting chmod for ipmi_pass file");
             }
         }
     }
@@ -116,7 +114,7 @@
     {
         if (passwdMapList.find(userName) == passwdMapList.end())
         {
-            log<level::DEBUG>("User not found");
+            lg2::debug("User not found");
             return 0;
         }
     }
@@ -124,11 +122,11 @@
     // Write passwdMap to Encryted file
     if (updatePasswdSpecialFile(userName, newUserName) != 0)
     {
-        log<level::DEBUG>("Passwd file update failed");
+        lg2::debug("Passwd file update failed");
         return -EIO;
     }
 
-    log<level::DEBUG>("Passwd file updated successfully");
+    lg2::debug("Passwd file updated successfully");
     return 0;
 }
 
@@ -137,7 +135,7 @@
     std::time_t updatedTime = getUpdatedFileTime();
     if (fileLastUpdatedTime != updatedTime && updatedTime != -1)
     {
-        log<level::DEBUG>("Reloading password map list");
+        lg2::debug("Reloading password map list");
         passwdMapList.clear();
         initPasswordMap();
     }
@@ -155,7 +153,7 @@
         (size_t)EVP_CIPHER_key_length(cipher) > keyLen ||
         (size_t)EVP_CIPHER_iv_length(cipher) > ivLen)
     {
-        log<level::DEBUG>("Error Invalid Inputs");
+        lg2::debug("Error Invalid Inputs");
         return -EINVAL;
     }
 
@@ -169,13 +167,13 @@
                          calMac.data(),
                          reinterpret_cast<unsigned int*>(&calMacLen)))
         {
-            log<level::DEBUG>("Error: Failed to calculate MAC");
+            lg2::debug("Error: Failed to calculate MAC");
             return -EIO;
         }
         if (!((calMacLen == *macLen) &&
               (std::memcmp(calMac.data(), mac, calMacLen) == 0)))
         {
-            log<level::DEBUG>("Authenticated message doesn't match");
+            lg2::debug("Authenticated message doesn't match");
             return -EBADMSG;
         }
     }
@@ -185,7 +183,7 @@
 
     if (!ctx)
     {
-        log<level::DEBUG>("Error: EVP_CIPHER_CTX is NULL");
+        lg2::debug("Error: EVP_CIPHER_CTX is NULL");
         return -ENOMEM;
     }
 
@@ -196,8 +194,7 @@
                                    static_cast<int>(doEncrypt));
     if (!retval)
     {
-        log<level::DEBUG>("EVP_CipherInit_ex failed",
-                          entry("RET_VAL=%d", retval));
+        lg2::debug("EVP_CipherInit_ex failed: {RET_VAL}", "RET_VAL", retval);
         return -EIO;
     }
 
@@ -214,15 +211,13 @@
         }
         else
         {
-            log<level::DEBUG>("EVP_CipherFinal fails",
-                              entry("RET_VAL=%d", retval));
+            lg2::debug("EVP_CipherFinal fails: {RET_VAL}", "RET_VAL", retval);
             return -EIO;
         }
     }
     else
     {
-        log<level::DEBUG>("EVP_CipherUpdate fails",
-                          entry("RET_VAL=%d", retval));
+        lg2::debug("EVP_CipherUpdate fails: {RET_VAL}", "RET_VAL", retval);
         return -EIO;
     }
 
@@ -232,7 +227,7 @@
         if (NULL == HMAC(EVP_sha256(), key, keyLen, outBytes, *outBytesLen, mac,
                          reinterpret_cast<unsigned int*>(macLen)))
         {
-            log<level::DEBUG>("Failed to create authentication");
+            lg2::debug("Failed to create authentication");
             return -EIO;
         }
     }
@@ -246,7 +241,7 @@
 
     if (readPasswdFileData(dataBuf) != 0)
     {
-        log<level::DEBUG>("Error in reading the encrypted pass file");
+        lg2::debug("Error in reading the encrypted pass file");
         return;
     }
 
@@ -283,20 +278,20 @@
     std::ifstream keyFile(encryptKeyFileName, std::ios::in | std::ios::binary);
     if (!keyFile.is_open())
     {
-        log<level::DEBUG>("Error in opening encryption key file");
+        lg2::debug("Error in opening encryption key file");
         return -EIO;
     }
     keyFile.read(reinterpret_cast<char*>(keyBuff.data()), keyBuff.size());
     if (keyFile.fail())
     {
-        log<level::DEBUG>("Error in reading encryption key file");
+        lg2::debug("Error in reading encryption key file");
         return -EIO;
     }
 
     std::ifstream passwdFile(passwdFileName, std::ios::in | std::ios::binary);
     if (!passwdFile.is_open())
     {
-        log<level::DEBUG>("Error in opening ipmi password file");
+        lg2::debug("Error in opening ipmi password file");
         return -EIO;
     }
 
@@ -308,7 +303,7 @@
     passwdFile.read(reinterpret_cast<char*>(input.data()), fileSize);
     if (passwdFile.fail())
     {
-        log<level::DEBUG>("Error in reading encryption key file");
+        lg2::debug("Error in reading encryption key file");
         return -EIO;
     }
 
@@ -317,7 +312,7 @@
     if (std::strncmp(metaData->signature, META_PASSWD_SIG,
                      sizeof(metaData->signature)))
     {
-        log<level::DEBUG>("Error signature mismatch in password file");
+        lg2::debug("Error signature mismatch in password file");
         return -EBADMSG;
     }
 
@@ -325,7 +320,7 @@
     // If data is empty i.e no password map then return success
     if (inBytesLen == 0)
     {
-        log<level::DEBUG>("Empty password file");
+        lg2::debug("Empty password file");
         return 0;
     }
 
@@ -336,7 +331,7 @@
                      input.data() + sizeof(*metaData), metaData->hashSize,
                      key.data(), reinterpret_cast<unsigned int*>(&keyLen)))
     {
-        log<level::DEBUG>("Failed to create MAC for authentication");
+        lg2::debug("Failed to create MAC for authentication");
         return -EIO;
     }
 
@@ -355,7 +350,7 @@
                            reinterpret_cast<unsigned char*>(outBytes.data()),
                            &outBytesLen) != 0)
     {
-        log<level::DEBUG>("Error in decryption");
+        lg2::debug("Error in decryption");
         return -EIO;
     }
     // Resize the vector to outBytesLen
@@ -382,7 +377,7 @@
     // Check user existance and return if not exist.
     if (readPasswdFileData(dataBuf) != 0)
     {
-        log<level::DEBUG>("Error in reading the encrypted pass file");
+        lg2::debug("Error in reading the encrypted pass file");
         return -EIO;
     }
 
@@ -430,7 +425,7 @@
     }
     if (!isUsrFound)
     {
-        log<level::DEBUG>("User doesn't exist");
+        lg2::debug("User doesn't exist");
         return 0;
     }
 
@@ -439,13 +434,13 @@
     std::ifstream keyFile(encryptKeyFileName, std::ios::in | std::ios::binary);
     if (!keyFile.good())
     {
-        log<level::DEBUG>("Error in opening encryption key file");
+        lg2::debug("Error in opening encryption key file");
         return -EIO;
     }
     keyFile.read(reinterpret_cast<char*>(keyBuff.data()), keyBuff.size());
     if (keyFile.fail())
     {
-        log<level::DEBUG>("Error in reading encryption key file");
+        lg2::debug("Error in reading encryption key file");
         return -EIO;
     }
     keyFile.close();
@@ -454,7 +449,7 @@
     struct stat st = {};
     if (stat(passwdFileName, &st) != 0)
     {
-        log<level::DEBUG>("Error in getting password file fstat()");
+        lg2::debug("Error in getting password file fstat()");
         return -EIO;
     }
 
@@ -468,7 +463,7 @@
     int fd = mkstemp((char*)tempFileName.data());
     if (fd == -1)
     {
-        log<level::DEBUG>("Error creating temp file");
+        lg2::debug("Error creating temp file");
         return -EIO;
     }
 
@@ -480,14 +475,14 @@
     if ((temp)() == NULL)
     {
         close(fd);
-        log<level::DEBUG>("Error creating temp file");
+        lg2::debug("Error creating temp file");
         return -EIO;
     }
 
     // Set the file mode as read-write for owner only
     if (fchmod(fileno((temp)()), S_IRUSR | S_IWUSR) < 0)
     {
-        log<level::DEBUG>("Error setting fchmod for temp file");
+        lg2::debug("Error setting fchmod for temp file");
         return -EIO;
     }
 
@@ -505,21 +500,21 @@
     // encryption.
     if (RAND_bytes(hash.data(), hashLen) != 1)
     {
-        log<level::DEBUG>("Hash genertion failed, bailing out");
+        lg2::debug("Hash genertion failed, bailing out");
         return -EIO;
     }
     if (NULL == HMAC(digest, keyBuff.data(), keyBuff.size(), hash.data(),
                      hashLen, key.data(),
                      reinterpret_cast<unsigned int*>(&keyLen)))
     {
-        log<level::DEBUG>("Failed to create MAC for authentication");
+        lg2::debug("Failed to create MAC for authentication");
         return -EIO;
     }
 
     // Generate IV values
     if (RAND_bytes(iv.data(), ivLen) != 1)
     {
-        log<level::DEBUG>("UV genertion failed, bailing out");
+        lg2::debug("UV genertion failed, bailing out");
         return -EIO;
     }
 
@@ -533,7 +528,7 @@
                 reinterpret_cast<unsigned char*>(inBytes.data()), inBytesLen,
                 mac.data(), &macLen, outBytes.data(), &outBytesLen) != 0)
         {
-            log<level::DEBUG>("Error while encrypting the data");
+            lg2::debug("Error while encrypting the data");
             return -EIO;
         }
         outBytes[outBytesLen] = 0;
@@ -550,38 +545,37 @@
 
     if (fwrite(&metaData, 1, sizeof(metaData), (temp)()) != sizeof(metaData))
     {
-        log<level::DEBUG>("Error in writing meta data");
+        lg2::debug("Error in writing meta data");
         return -EIO;
     }
 
     if (fwrite(&hash[0], 1, hashLen, (temp)()) != hashLen)
     {
-        log<level::DEBUG>("Error in writing hash data");
+        lg2::debug("Error in writing hash data");
         return -EIO;
     }
 
     if (fwrite(&iv[0], 1, ivLen, (temp)()) != ivLen)
     {
-        log<level::DEBUG>("Error in writing IV data");
+        lg2::debug("Error in writing IV data");
         return -EIO;
     }
 
     if (fwrite(&outBytes[0], 1, outBytesLen, (temp)()) != outBytesLen)
     {
-        log<level::DEBUG>("Error in writing encrypted data");
+        lg2::debug("Error in writing encrypted data");
         return -EIO;
     }
 
     if (fwrite(&mac[0], 1, macLen, (temp)()) != macLen)
     {
-        log<level::DEBUG>("Error in writing MAC data");
+        lg2::debug("Error in writing MAC data");
         return -EIO;
     }
 
     if (fflush((temp)()))
     {
-        log<level::DEBUG>(
-            "File fflush error while writing entries to special file");
+        lg2::debug("File fflush error while writing entries to special file");
         return -EIO;
     }
 
@@ -590,7 +584,7 @@
     // Rename the tmp  file to actual file
     if (std::rename(strTempFileName.data(), passwdFileName) != 0)
     {
-        log<level::DEBUG>("Failed to rename tmp file to ipmi-pass");
+        lg2::debug("Failed to rename tmp file to ipmi-pass");
         return -EIO;
     }
 
@@ -602,7 +596,7 @@
     struct stat fileStat = {};
     if (stat(passwdFileName, &fileStat) != 0)
     {
-        log<level::DEBUG>("Error - Getting passwd file time stamp");
+        lg2::debug("Error - Getting passwd file time stamp");
         return -EIO;
     }
     return fileStat.st_mtime;
diff --git a/user_channel/shadowlock.hpp b/user_channel/shadowlock.hpp
index c869aca..1dc5f3b 100644
--- a/user_channel/shadowlock.hpp
+++ b/user_channel/shadowlock.hpp
@@ -3,6 +3,7 @@
 #include <shadow.h>
 
 #include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 namespace phosphor
 {
@@ -31,7 +32,7 @@
     {
         if (!lckpwdf())
         {
-            log<level::ERR>("Locking Shadow failed");
+            lg2::error("Locking Shadow failed");
             elog<InternalFailure>();
         }
     }
@@ -39,7 +40,7 @@
     {
         if (!ulckpwdf())
         {
-            log<level::ERR>("Un-Locking Shadow failed");
+            lg2::error("Un-Locking Shadow failed");
             elog<InternalFailure>();
         }
     }
diff --git a/user_channel/user_mgmt.cpp b/user_channel/user_mgmt.cpp
index 00ed142..979aaa6 100644
--- a/user_channel/user_mgmt.cpp
+++ b/user_channel/user_mgmt.cpp
@@ -28,7 +28,7 @@
 #include <ipmid/types.hpp>
 #include <nlohmann/json.hpp>
 #include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/bus/match.hpp>
 #include <sdbusplus/server/object.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
@@ -166,10 +166,10 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>("Failed to set property",
-                        entry("PROPERTY=%s", property.c_str()),
-                        entry("PATH=%s", objPath.c_str()),
-                        entry("INTERFACE=%s", interface.c_str()));
+        lg2::error("Failed to set {PROPERTY}, path: {PATH}, "
+                   "interface: {INTERFACE}",
+                   "PROPERTY", property, "PATH", objPath, "INTERFACE",
+                   interface);
         throw;
     }
 }
@@ -234,9 +234,9 @@
         }
         if (usrIndex > ipmiMaxUsers)
         {
-            log<level::DEBUG>("User not found for signal",
-                              entry("USER_NAME=%s", userName.c_str()),
-                              entry("USER_EVENT=%d", userEvent));
+            lg2::debug("User not found for signal, user name: {USER_NAME}, "
+                       "user event: {USER_EVENT}",
+                       "USER_NAME", userName, "USER_EVENT", userEvent);
             return;
         }
         switch (userEvent)
@@ -288,16 +288,16 @@
             }
             default:
             {
-                log<level::ERR>("Unhandled user event",
-                                entry("USER_EVENT=%d", userEvent));
+                lg2::error("Unhandled user event: {USER_EVENT}", "USER_EVENT",
+                           userEvent);
                 return;
             }
         }
     }
     usrAccess.writeUserData();
-    log<level::DEBUG>("User event handled successfully",
-                      entry("USER_NAME=%s", userName.c_str()),
-                      entry("USER_EVENT=%d", userEvent));
+    lg2::debug("User event handled successfully, user name: {USER_NAME}, "
+               "user event: {USER_EVENT}",
+               "USER_NAME", userName.c_str(), "USER_EVENT", userEvent);
 
     return;
 }
@@ -347,15 +347,14 @@
     }
     else
     {
-        log<level::ERR>("Unknown user update signal",
-                        entry("SIGNAL=%s", signal.c_str()));
+        lg2::error("Unknown user update signal: {SIGNAL}", "SIGNAL", signal);
         return;
     }
 
     if (signal.empty() || userName.empty() ||
         (signal == userRenamedSignal && newUserName.empty()))
     {
-        log<level::ERR>("Invalid inputs received");
+        lg2::error("Invalid inputs received");
         return;
     }
 
@@ -411,10 +410,9 @@
                     }
                     catch (const sdbusplus::exception_t& e)
                     {
-                        log<level::DEBUG>(
-                            "Failed to excute method",
-                            entry("METHOD=%s", getAllPropertiesMethod),
-                            entry("PATH=%s", msg.get_path()));
+                        lg2::debug("Failed to excute {METHOD}, path: {PATH}",
+                                   "METHOD", getAllPropertiesMethod, "PATH",
+                                   msg.get_path());
                         return;
                     }
                     usrAccess.getUserProperties(properties, groups, priv,
@@ -457,7 +455,7 @@
                           std::ofstream::out | std::ofstream::app);
     if (!mutexCleanUpFile.good())
     {
-        log<level::DEBUG>("Unable to open mutex cleanup file");
+        lg2::debug("Unable to open mutex cleanup file");
         return;
     }
     mutexCleanUpFile.close();
@@ -527,8 +525,8 @@
         {
             return static_cast<CommandPrivilege>(privNoAccess);
         }
-        log<level::ERR>("Error in converting to IPMI privilege",
-                        entry("PRIV=%s", value.c_str()));
+        lg2::error("Error in converting to IPMI privilege: {PRIV}", "PRIV",
+                   value);
         throw std::out_of_range("Out of range - convertToIPMIPrivilege");
     }
     else
@@ -550,8 +548,8 @@
     }
     catch (const std::out_of_range& e)
     {
-        log<level::ERR>("Error in converting to system privilege",
-                        entry("PRIV=%d", static_cast<uint8_t>(value)));
+        lg2::error("Error in converting to system privilege: {PRIV}", "PRIV",
+                   value);
         throw std::out_of_range("Out of range - convertToSystemPrivilege");
     }
 }
@@ -560,18 +558,18 @@
 {
     if (userName.empty())
     {
-        log<level::ERR>("userName is empty");
+        lg2::error("userName is empty");
         return false;
     }
     if (!std::regex_match(userName.c_str(),
                           std::regex("[a-zA-Z_][a-zA-Z_0-9]*")))
     {
-        log<level::ERR>("Unsupported characters in user name");
+        lg2::error("Unsupported characters in user name");
         return false;
     }
     if (userName == "root")
     {
-        log<level::ERR>("Invalid user name - root");
+        lg2::error("Invalid user name - root");
         return false;
     }
     std::map<DbusUserObjPath, DbusUserObjValue> properties;
@@ -585,9 +583,8 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>("Failed to excute method",
-                        entry("METHOD=%s", getManagedObjectsMethod),
-                        entry("PATH=%s", userMgrObjBasePath));
+        lg2::error("Failed to excute {METHOD}, path: {PATH}", "METHOD",
+                   getManagedObjectsMethod, "PATH", userMgrObjBasePath);
         return false;
     }
 
@@ -597,8 +594,8 @@
 
     if (properties.find(usersPath) != properties.end())
     {
-        log<level::DEBUG>("User name already exists",
-                          entry("USER_NAME=%s", userName.c_str()));
+        lg2::debug("Username {USER_NAME} already exists", "USER_NAME",
+                   userName);
         return false;
     }
 
@@ -719,7 +716,7 @@
     if (pam_start("dropbear", username.data(), &localConversation,
                   &localAuthHandle) != PAM_SUCCESS)
     {
-        log<level::ERR>("User Authentication Failure");
+        lg2::error("User Authentication Failure");
         return false;
     }
 
@@ -728,8 +725,8 @@
 
     if (retval != PAM_SUCCESS)
     {
-        log<level::DEBUG>("pam_authenticate returned failure",
-                          entry("ERROR=%d", retval));
+        lg2::debug("pam_authenticate returned failure: {ERROR}", "ERROR",
+                   retval);
 
         pam_end(localAuthHandle, retval);
         return false;
@@ -754,7 +751,7 @@
 {
     if (pamUpdatePasswd(userName.c_str(), userPassword.c_str()) != PAM_SUCCESS)
     {
-        log<level::DEBUG>("Failed to update password");
+        lg2::debug("Failed to update password");
         return ccUnspecifiedError;
     }
     return ccSuccess;
@@ -765,8 +762,8 @@
     std::string userName;
     if (ipmiUserGetUserName(userId, userName) != ccSuccess)
     {
-        log<level::DEBUG>("User Name not found",
-                          entry("USER-ID=%d", (uint8_t)userId));
+        lg2::debug("User Name not found, user Id: {USER_ID}", "USER_ID",
+                   userId);
         return ccParmOutOfRange;
     }
 
@@ -783,13 +780,13 @@
         }
         case PAM_AUTHTOK_ERR:
         {
-            log<level::DEBUG>("Bad authentication token");
+            lg2::debug("Bad authentication token");
             return ccInvalidFieldRequest;
         }
         default:
         {
-            log<level::DEBUG>("Failed to update password",
-                              entry("USER-ID=%d", (uint8_t)userId));
+            lg2::debug("Failed to update password, user Id: {USER_ID}",
+                       "USER_ID", userId);
             return ccUnspecifiedError;
         }
     }
@@ -810,7 +807,7 @@
                     ipmiMaxUserName);
     if (userName.empty())
     {
-        log<level::DEBUG>("User name not set / invalid");
+        lg2::debug("User name not set / invalid");
         return ccUnspecifiedError;
     }
     if (userInfo->userEnabled != enabledState)
@@ -827,7 +824,7 @@
         }
         catch (const std::exception& e)
         {
-            log<level::DEBUG>("Write user data failed");
+            lg2::debug("Write user data failed");
             return ccUnspecifiedError;
         }
     }
@@ -882,7 +879,7 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("Write user data failed");
+        lg2::error("Write user data failed");
         return ccUnspecifiedError;
     }
     return ccSuccess;
@@ -908,7 +905,7 @@
                     ipmiMaxUserName);
     if (userName.empty())
     {
-        log<level::DEBUG>("User name not set / invalid");
+        lg2::debug("User name not set / invalid");
         return ccUnspecifiedError;
     }
     std::string priv = convertToSystemPrivilege(
@@ -939,7 +936,7 @@
     }
     catch (const std::exception& e)
     {
-        log<level::DEBUG>("Write user data failed");
+        lg2::debug("Write user data failed");
         return ccUnspecifiedError;
     }
     return ccSuccess;
@@ -964,8 +961,7 @@
     }
     if (usrIndex > ipmiMaxUsers)
     {
-        log<level::DEBUG>("User not found",
-                          entry("USER_NAME=%s", userName.c_str()));
+        lg2::debug("Username {USER_NAME} not found", "USER_NAME", userName);
         return invalidUserId;
     }
 
@@ -1039,9 +1035,8 @@
         }
         catch (const sdbusplus::exception_t& e)
         {
-            log<level::DEBUG>("Failed to excute method",
-                              entry("METHOD=%s", deleteUserMethod),
-                              entry("PATH=%s", userPath.c_str()));
+            lg2::debug("Failed to excute {METHOD}, path:{PATH}", "METHOD",
+                       deleteUserMethod, "PATH", userPath);
             return ccUnspecifiedError;
         }
         deleteUserIndex(userId);
@@ -1064,9 +1059,8 @@
         }
         catch (const sdbusplus::exception_t& e)
         {
-            log<level::DEBUG>("Failed to excute method",
-                              entry("METHOD=%s", createUserMethod),
-                              entry("PATH=%s", userMgrObjBasePath));
+            lg2::debug("Failed to excute {METHOD}, path: {PATH}", "METHOD",
+                       createUserMethod, "PATH", userMgrObjBasePath);
             return ccUnspecifiedError;
         }
 
@@ -1093,9 +1087,8 @@
         }
         catch (const sdbusplus::exception_t& e)
         {
-            log<level::DEBUG>("Failed to excute method",
-                              entry("METHOD=%s", renameUserMethod),
-                              entry("PATH=%s", userMgrObjBasePath));
+            lg2::debug("Failed to excute {METHOD}, path: {PATH}", "METHOD",
+                       renameUserMethod, "PATH", userMgrObjBasePath);
             return ccUnspecifiedError;
         }
         std::fill(static_cast<uint8_t*>(userInfo->userName),
@@ -1120,7 +1113,7 @@
     }
     catch (const std::exception& e)
     {
-        log<level::DEBUG>("Write user data failed");
+        lg2::debug("Write user data failed");
         return ccUnspecifiedError;
     }
     return ccSuccess;
@@ -1234,7 +1227,7 @@
     std::ifstream iUsrData(ipmiUserDataFile, std::ios::in | std::ios::binary);
     if (!iUsrData.good())
     {
-        log<level::ERR>("Error in reading IPMI user data file");
+        lg2::error("Error in reading IPMI user data file");
         throw std::ios_base::failure("Error opening IPMI user data file");
     }
 
@@ -1243,8 +1236,7 @@
 
     if (jsonUsersTbl.size() != ipmiMaxUsers)
     {
-        log<level::ERR>(
-            "Error in reading IPMI user data file - User count issues");
+        lg2::error("Error in reading IPMI user data file - User count issues");
         throw std::runtime_error(
             "Corrupted IPMI user data file - invalid user count");
     }
@@ -1255,8 +1247,8 @@
         Json userInfo = jsonUsersTbl[usrIndex - 1]; // json array starts with 0.
         if (userInfo.is_null())
         {
-            log<level::ERR>("Error in reading IPMI user data file - "
-                            "user info corrupted");
+            lg2::error("Error in reading IPMI user data file - "
+                       "user info corrupted");
             throw std::runtime_error(
                 "Corrupted IPMI user data file - invalid user info");
         }
@@ -1300,8 +1292,8 @@
                 if (stdPayload[payloadNum].size() != ipmiMaxChannels ||
                     oemPayload[payloadNum].size() != ipmiMaxChannels)
                 {
-                    log<level::ERR>("Error in reading IPMI user data file - "
-                                    "payload properties corrupted");
+                    lg2::error("Error in reading IPMI user data file - "
+                               "payload properties corrupted");
                     throw std::runtime_error(
                         "Corrupted IPMI user data file - payload properties");
                 }
@@ -1319,8 +1311,8 @@
             linkAuthEnabled.size() != ipmiMaxChannels ||
             accessCallback.size() != ipmiMaxChannels)
         {
-            log<level::ERR>("Error in reading IPMI user data file - "
-                            "properties corrupted");
+            lg2::error("Error in reading IPMI user data file - "
+                       "properties corrupted");
             throw std::runtime_error(
                 "Corrupted IPMI user data file - properties");
         }
@@ -1346,7 +1338,7 @@
             userInfo[jsonFixedUser].get<bool>();
     }
 
-    log<level::DEBUG>("User data read from IPMI data file");
+    lg2::debug("User data read from IPMI data file");
     iUsrData.close();
     // Update the timestamp
     fileLastUpdatedTime = getUpdatedFileTime();
@@ -1410,7 +1402,7 @@
                   S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
     if (fd < 0)
     {
-        log<level::ERR>("Error in creating temporary IPMI user data file");
+        lg2::error("Error in creating temporary IPMI user data file");
         throw std::ios_base::failure(
             "Error in creating temporary IPMI user data file");
     }
@@ -1419,7 +1411,7 @@
         static_cast<ssize_t>(writeStr.size()))
     {
         close(fd);
-        log<level::ERR>("Error in writing temporary IPMI user data file");
+        lg2::error("Error in writing temporary IPMI user data file");
         throw std::ios_base::failure(
             "Error in writing temporary IPMI user data file");
     }
@@ -1427,7 +1419,7 @@
 
     if (std::rename(tmpFile.c_str(), ipmiUserDataFile) != 0)
     {
-        log<level::ERR>("Error in renaming temporary IPMI user data file");
+        lg2::error("Error in renaming temporary IPMI user data file");
         throw std::runtime_error("Error in renaming IPMI user data file");
     }
     // Update the timestamp
@@ -1448,8 +1440,7 @@
             ipmiMaxUserName);
         if (userName == curName)
         {
-            log<level::DEBUG>("User name exists",
-                              entry("USER_NAME=%s", userName.c_str()));
+            lg2::debug("Username {USER_NAME} exists", "USER_NAME", userName);
             return false; // user name exists.
         }
 
@@ -1462,7 +1453,7 @@
     }
     if (freeIndex == 0xFF)
     {
-        log<level::ERR>("No empty slots found");
+        lg2::error("No empty slots found");
         return false;
     }
     std::strncpy(reinterpret_cast<char*>(userData->user[freeIndex].userName),
@@ -1544,9 +1535,8 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::DEBUG>("Failed to excute method",
-                          entry("METHOD=%s", getAllPropertiesMethod),
-                          entry("PATH=%s", userMgrObjBasePath));
+        lg2::debug("Failed to excute {METHOD}, path: {PATH}", "METHOD",
+                   getAllPropertiesMethod, "PATH", userMgrObjBasePath);
         return;
     }
     for (const auto& t : properties)
@@ -1570,7 +1560,7 @@
     struct stat fileStat;
     if (stat(ipmiUserDataFile, &fileStat) != 0)
     {
-        log<level::DEBUG>("Error in getting last updated time stamp");
+        lg2::debug("Error in getting last updated time stamp");
         return std::timespec{0, 0};
     }
     return fileStat.st_mtim;
@@ -1644,7 +1634,7 @@
                   S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
     if (fd < 0)
     {
-        log<level::ERR>("Error in creating IPMI user signal lock file");
+        lg2::error("Error in creating IPMI user signal lock file");
         throw std::ios_base::failure(
             "Error in creating temporary IPMI user signal lock file");
     }
@@ -1655,7 +1645,7 @@
     // host-ipmid
     if (userUpdatedSignal == nullptr && sigHndlrLock.try_lock())
     {
-        log<level::DEBUG>("Registering signal handler");
+        lg2::debug("Registering signal handler");
         userUpdatedSignal = std::make_unique<sdbusplus::bus::match_t>(
             bus,
             sdbusplus::bus::match::rules::type::signal() +
@@ -1696,9 +1686,8 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::DEBUG>("Failed to excute method",
-                          entry("METHOD=%s", getManagedObjectsMethod),
-                          entry("PATH=%s", userMgrObjBasePath));
+        lg2::debug("Failed to excute {METHOD}, path: {PATH}", "METHOD",
+                   getManagedObjectsMethod, "PATH", userMgrObjBasePath);
         return;
     }
     bool updateRequired = false;
@@ -1783,7 +1772,7 @@
         std::string usrObjPath = std::string(usrObj.first);
         if (getUserNameFromPath(usrObj.first.str, userName) != 0)
         {
-            log<level::ERR>("Error in user object path");
+            lg2::error("Error in user object path");
             continue;
         }
         getUserObjProperties(usrObj.second, usrGrps, usrPriv, usrEnabled);
diff --git a/user_channel/usercommands.cpp b/user_channel/usercommands.cpp
index 6467e45..53b34f8 100644
--- a/user_channel/usercommands.cpp
+++ b/user_channel/usercommands.cpp
@@ -23,15 +23,13 @@
 #include <security/pam_appl.h>
 
 #include <ipmid/api.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <regex>
 
 namespace ipmi
 {
 
-using namespace phosphor::logging;
-
 static constexpr uint8_t enableOperation = 0x00;
 static constexpr uint8_t disableOperation = 0x01;
 
@@ -64,7 +62,7 @@
     if (reserved1 || reserved2 || sessLimit ||
         !ipmiUserIsValidPrivilege(static_cast<uint8_t>(privilege)))
     {
-        log<level::DEBUG>("Set user access - Invalid field in request");
+        lg2::debug("Set user access - Invalid field in request");
         return ipmi::responseInvalidFieldRequest();
     }
 
@@ -72,17 +70,17 @@
                                              ctx->channel);
     if (!isValidChannel(chNum))
     {
-        log<level::DEBUG>("Set user access - Invalid channel request");
+        lg2::debug("Set user access - Invalid channel request");
         return ipmi::response(invalidChannel);
     }
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
-        log<level::DEBUG>("Set user access - No support on channel");
+        lg2::debug("Set user access - No support on channel");
         return ipmi::response(ccActionNotSupportedForChannel);
     }
     if (!ipmiUserIsValidUserId(static_cast<uint8_t>(userId)))
     {
-        log<level::DEBUG>("Set user access - Parameter out of range");
+        lg2::debug("Set user access - Parameter out of range");
         return ipmi::responseParmOutOfRange();
     }
 
@@ -144,18 +142,18 @@
 
     if (reserved1 || reserved2 || !isValidChannel(chNum))
     {
-        log<level::DEBUG>("Get user access - Invalid field in request");
+        lg2::debug("Get user access - Invalid field in request");
         return ipmi::responseInvalidFieldRequest();
     }
 
     if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
     {
-        log<level::DEBUG>("Get user access - No support on channel");
+        lg2::debug("Get user access - No support on channel");
         return ipmi::response(ccActionNotSupportedForChannel);
     }
     if (!ipmiUserIsValidUserId(static_cast<uint8_t>(userId)))
     {
-        log<level::DEBUG>("Get user access - Parameter out of range");
+        lg2::debug("Get user access - Parameter out of range");
         return ipmi::responseParmOutOfRange();
     }
 
@@ -219,7 +217,7 @@
     uint8_t userId = static_cast<uint8_t>(id);
     if (!ipmiUserIsValidUserId(userId))
     {
-        log<level::DEBUG>("Set user name - Invalid user id");
+        lg2::debug("Set user name - Invalid user id");
         return ipmi::responseParmOutOfRange();
     }
 
@@ -252,7 +250,8 @@
     std::string userName;
     if (ipmiUserGetUserName(userId, userName) != ccSuccess)
     { // Invalid User ID
-        log<level::DEBUG>("User Name not found", entry("USER-ID=%u", userId));
+        lg2::debug("User Name not found, user Id: {USER_ID}", "USER_ID",
+                   userId);
         return ipmi::responseParmOutOfRange();
     }
     // copy the std::string into a fixed array
@@ -280,7 +279,7 @@
 {
     if (reserved1 || reserved2)
     {
-        log<level::DEBUG>("Invalid data field in request");
+        lg2::debug("Invalid data field in request");
         return ipmi::responseInvalidFieldRequest();
     }
 
@@ -295,7 +294,7 @@
         ((pwLen20 && (userPassword.size() != maxIpmi20PasswordSize)) ||
          (!pwLen20 && (userPassword.size() != maxIpmi15PasswordSize))))
     {
-        log<level::DEBUG>("Invalid Length");
+        lg2::debug("Invalid Length");
         return ipmi::responseReqDataLenInvalid();
     }
 
@@ -305,7 +304,8 @@
     std::string userName;
     if (ipmiUserGetUserName(userId, userName) != ccSuccess)
     {
-        log<level::DEBUG>("User Name not found", entry("USER-ID=%d", userId));
+        lg2::debug("User Name not found, user Id: {USER_ID}", "USER_ID",
+                   userId);
         return ipmi::responseParmOutOfRange();
     }
 
@@ -352,8 +352,8 @@
         pwBad |= pwLenDiffers;
         if (pwBad)
         {
-            log<level::DEBUG>("Test password failed",
-                              entry("USER-ID=%d", userId));
+            lg2::debug("Test password failed, user Id: {USER_ID}", "USER_ID",
+                       userId);
             static constexpr ipmi::Cc ipmiCCPasswdFailMismatch = 0x80;
             return ipmi::response(ipmiCCPasswdFailMismatch);
         }
@@ -417,15 +417,13 @@
     if (reserved1 || reserved2 || !isValidChannel(channel) ||
         !isValidPrivLimit(static_cast<uint8_t>(privLevel)))
     {
-        log<level::DEBUG>(
-            "Get channel auth capabilities - Invalid field in request");
+        lg2::debug("Get channel auth capabilities - Invalid field in request");
         return ipmi::responseInvalidFieldRequest();
     }
 
     if (getChannelSessionSupport(channel) == EChannelSessSupported::none)
     {
-        log<level::DEBUG>(
-            "Get channel auth capabilities - No support on channel");
+        lg2::debug("Get channel auth capabilities - No support on channel");
         return ipmi::response(ccActionNotSupportedForChannel);
     }
 
