diff --git a/app.cpp b/app.cpp
index 18453bb..291d9cf 100644
--- a/app.cpp
+++ b/app.cpp
@@ -9,13 +9,9 @@
 #endif
 
 #include <org/open_power/OCC/Device/error.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
-using namespace phosphor::logging;
-
 using namespace sdbusplus::org::open_power::OCC::Device::Error;
 using InternalFailure =
     sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
@@ -29,7 +25,7 @@
     auto r = sd_event_default(&event);
     if (r < 0)
     {
-        log<level::ERR>("Error creating a default sd_event handler");
+        lg2::error("Error creating a default sd_event handler");
         return r;
     }
     open_power::occ::EventPtr eventP{event};
diff --git a/occ_command.cpp b/occ_command.cpp
index 0b9faa1..30d8424 100644
--- a/occ_command.cpp
+++ b/occ_command.cpp
@@ -7,13 +7,10 @@
 #include <unistd.h>
 
 #include <org/open_power/OCC/Device/error.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <algorithm>
 #include <format>
-#include <memory>
 #include <string>
 
 // #define TRACE_PACKETS
@@ -23,8 +20,6 @@
 namespace occ
 {
 
-using namespace phosphor::logging;
-
 // Trace block of data in hex
 void dump_hex(const std::vector<std::uint8_t>& data,
               const unsigned int data_len)
@@ -50,7 +45,7 @@
 
         if ((i % 16 == 15) || (i == (dump_length - 1)))
         {
-            log<level::INFO>(s.c_str());
+            lg2::info("{STRING}", "STRING", s);
             s.clear();
         }
     }
@@ -65,32 +60,27 @@
         std::bind(std::mem_fn(&OccCommand::activeStatusEvent), this,
                   std::placeholders::_1))
 {
-    log<level::DEBUG>(
-        std::format("OccCommand::OccCommand(path={}, devicePath={}", this->path,
-                    devicePath)
-            .c_str());
+    lg2::debug("OccCommand::OccCommand(path={PATH}, devicePath={DEVICE}",
+               "PATH", this->path, "DEVICE", devicePath);
 }
 
 void OccCommand::openDevice()
 {
     using namespace sdbusplus::org::open_power::OCC::Device::Error;
 
-    log<level::DEBUG>(
-        std::format("OccCommand::openDevice: calling open {}", devicePath)
-            .c_str());
+    lg2::debug("OccCommand::openDevice: calling open {PATH}", "PATH",
+               devicePath);
     fd = open(devicePath.c_str(), O_RDWR | O_NONBLOCK);
     if (fd < 0)
     {
         const int openErrno = errno;
-        log<level::ERR>(
-            std::format(
-                "OccCommand::openDevice: open failed (errno={}, path={})",
-                openErrno, devicePath)
-                .c_str());
+        lg2::error(
+            "OccCommand::openDevice: open failed (errno={ERR}, path={PATH})",
+            "ERR", openErrno, "PATH", devicePath);
     }
     else
     {
-        log<level::DEBUG>("OccCommand::openDevice: open success");
+        lg2::debug("OccCommand::openDevice: open success");
     }
 
     return;
@@ -100,7 +90,7 @@
 {
     if (fd >= 0)
     {
-        log<level::DEBUG>("OccCommand::closeDevice: calling close()");
+        lg2::debug("OccCommand::closeDevice: calling close()");
         close(fd);
         fd = -1;
     }
@@ -114,7 +104,7 @@
 
     response.clear();
 
-    log<level::DEBUG>("OccCommand::send: calling openDevice()");
+    lg2::debug("OccCommand::send: calling openDevice()");
     openDevice();
 
     if (fd < 0)
@@ -125,13 +115,12 @@
 
     const uint8_t cmd_type = command[0];
 #ifdef TRACE_PACKETS
-    log<level::INFO>(
-        std::format("OCC{}: Sending 0x{:02X} command (length={}, {})",
-                    occInstance, cmd_type, command.size(), devicePath)
-            .c_str());
+    lg2::info("OCC{INST}: Sending {CMD} command (length={LEN}, {PATH})", "INST",
+              occInstance, "CMD", lg2::hex, cmd_type, "LEN", command.size(),
+              "PATH", devicePath);
     dump_hex(command);
 #else
-    log<level::DEBUG>("OccCommand::send: calling write()");
+    lg2::debug("OccCommand::send: calling write()");
 #endif
 
     int retries = 1; // Allow a retry if a command fails to get valid response
@@ -141,18 +130,17 @@
         const int writeErrno = errno;
         if ((rc < 0) || (rc != (int)command.size()))
         {
-            log<level::ERR>(
-                std::format(
-                    "OccCommand::send: write(OCC{}, command:0x{:02X}) failed with errno={} (retries={})",
-                    occInstance, cmd_type, writeErrno, retries)
-                    .c_str());
+            lg2::error(
+                "OccCommand::send: write(OCC{INST}, command:{CMD}) failed with errno={ERR} (retries={RETRIES})",
+                "INST", occInstance, "CMD", lg2::hex, cmd_type, "ERR",
+                writeErrno, "RETRIES", retries);
             status = CmdStatus::COMM_FAILURE;
             // retry if available
             continue;
         }
         else
         {
-            log<level::DEBUG>("OccCommand::send: write succeeded");
+            lg2::debug("OccCommand::send: write succeeded");
         }
 
         // Now read the response. This would be the content of occ-sram
@@ -173,19 +161,17 @@
             }
             else if (len == 0)
             {
-                log<level::DEBUG>("OccCommand::send: read completed");
+                lg2::debug("OccCommand::send: read completed");
                 // We have read all that we can.
                 status = CmdStatus::SUCCESS;
                 break;
             }
             else
             {
-                log<level::ERR>(
-                    std::format(
-                        "OccCommand::send: read(OCC{}, command:0x{:02X}) failed with errno={} (rspSize={}, retries={})",
-                        occInstance, cmd_type, readErrno, response.size(),
-                        retries)
-                        .c_str());
+                lg2::error(
+                    "OccCommand::send: read(OCC{INST}, command:{CMD) failed with errno={ERR} (rspSize={LEN}, retries={RETRIES})",
+                    "INST", occInstance, "CMD", lg2::hex, cmd_type, "ERR",
+                    readErrno, "LEN", response.size(), "RETRIES", retries);
                 status = CmdStatus::COMM_FAILURE;
                 break;
             }
@@ -199,11 +185,10 @@
         if (response.size() > 2)
         {
 #ifdef TRACE_PACKETS
-            log<level::INFO>(
-                std::format(
-                    "OCC{}: Received 0x{:02X} response (length={} w/checksum)",
-                    occInstance, cmd_type, response.size())
-                    .c_str());
+            lg2::info(
+                "OCC{INST}: Received {CMD} response (length={LEN} w/checksum)",
+                "INST", occInstance, "CMD", lg2::hex, cmd_type, "LEN",
+                response.size());
             dump_hex(response, 64);
 #endif
 
@@ -219,11 +204,10 @@
             }
             if (calcChecksum != rspChecksum)
             {
-                log<level::ERR>(
-                    std::format("OCC{}: Checksum Mismatch: response "
-                                "0x{:04X}, calculated 0x{:04X}",
-                                occInstance, rspChecksum, calcChecksum)
-                        .c_str());
+                lg2::error("OCC{INST}: Checksum Mismatch: response "
+                           "{RCVD}, calculated {EXPECT}",
+                           "INST", occInstance, "RCVD", rspChecksum, "EXPECT",
+                           calcChecksum);
                 dump_hex(response);
                 status = CmdStatus::COMM_FAILURE;
             }
@@ -241,31 +225,27 @@
                 }
                 else
                 {
-                    log<level::ERR>(
-                        std::format(
-                            "OccCommand::send: Response command mismatch "
-                            "(sent: "
-                            "0x{:02X}, rsp: 0x{:02X}, rsp seq#: 0x{:02X}",
-                            command[0], response[1], response[0])
-                            .c_str());
+                    lg2::error("OccCommand::send: Response command mismatch "
+                               "(sent: "
+                               "{CMD}, rsp: {STATUS}, rsp seq#: {SEQ}",
+                               "CMD", lg2::hex, command[0], "STATUS", lg2::hex,
+                               response[1], "SEQ", lg2::hex, response[0]);
                     dump_hex(response, 64);
                 }
             }
         }
         else
         {
-            log<level::ERR>(
-                std::format(
-                    "OccCommand::send: Invalid OCC{} response length: {}",
-                    occInstance, response.size())
-                    .c_str());
+            lg2::error(
+                "OccCommand::send: Invalid OCC{INST} response length: {LEN}",
+                "INST", occInstance, "LEN", response.size());
             status = CmdStatus::FAILURE;
             dump_hex(response);
         }
 
         if (retries > 0)
         {
-            log<level::ERR>("OccCommand::send: Command will be retried");
+            lg2::error("OccCommand::send: Command will be retried");
             response.clear();
         }
     } while (retries-- > 0);
diff --git a/occ_command.hpp b/occ_command.hpp
index 2adf573..bbebe06 100644
--- a/occ_command.hpp
+++ b/occ_command.hpp
@@ -80,7 +80,7 @@
     COMM_FAILURE = 0x03
 };
 
-/** @brief Trace block of data in hex with log<level:INFO>
+/** @brief Trace block of data in hex with lg2:info()
  *
  *  @param[in] data - vector containing data to trace
  *  @param[in] data_len - optional number of bytes to trace
diff --git a/occ_dbus.cpp b/occ_dbus.cpp
index 96d4554..e018246 100644
--- a/occ_dbus.cpp
+++ b/occ_dbus.cpp
@@ -2,9 +2,8 @@
 
 #include "utils.hpp"
 
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
-#include <format>
 #include <iostream>
 
 namespace open_power
@@ -14,7 +13,6 @@
 namespace dbus
 {
 
-using namespace phosphor::logging;
 using namespace std::string_literals;
 const auto defaultChassisPath =
     "/xyz/openbmc_project/inventory/system/chassis"s;
@@ -120,7 +118,7 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>("set Unit propety failed", entry("ERROR=%s", e.what()));
+        lg2::error("set Unit propety failed: error={ERR}", "ERR", e.what());
         return false;
     }
 
@@ -137,8 +135,7 @@
         }
         catch (const std::exception& e)
         {
-            log<level::ERR>("get Unit propety failed",
-                            entry("ERROR=%s", e.what()));
+            lg2::error("get Unit propety failed: error={ERR}", "ERR", e.what());
         }
     }
 
@@ -217,11 +214,8 @@
         else if (std::find(paths.begin(), paths.end(), defaultChassisPath) ==
                  paths.end())
         {
-            log<level::ERR>(
-                std::format(
-                    "Could not find a chassis out of {} chassis objects",
-                    paths.size())
-                    .c_str());
+            lg2::error("Could not find a chassis out of {NUM} chassis objects",
+                       "NUM", paths.size());
             // Can't throw an exception here, the sdeventplus timer
             // just catches it.
             abort();
@@ -229,9 +223,7 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>(
-            std::format("Error looking up chassis objects: {}", e.what())
-                .c_str());
+        lg2::error("Error looking up chassis objects: {ERR}", "ERR", e.what());
         abort();
     }
 
diff --git a/occ_device.cpp b/occ_device.cpp
index ded5db9..98eeab7 100644
--- a/occ_device.cpp
+++ b/occ_device.cpp
@@ -3,7 +3,7 @@
 #include "occ_manager.hpp"
 #include "occ_status.hpp"
 
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <filesystem>
 #include <iostream>
@@ -13,8 +13,6 @@
 namespace occ
 {
 
-using namespace phosphor::logging;
-
 void Device::setActive(bool active)
 {
     std::string data = active ? "1" : "0";
@@ -25,9 +23,8 @@
     }
     catch (const std::exception& e)
     {
-        log<level::ERR>(std::format("Failed to set {} active: {}",
-                                    devPath.c_str(), e.what())
-                            .c_str());
+        lg2::error("Failed to set {DEVICE} active: {ERROR}", "DEVICE", devPath,
+                   "ERROR", e.what());
     }
 }
 
@@ -151,10 +148,8 @@
     }
     catch (const fs::filesystem_error& e)
     {
-        log<level::ERR>(
-            std::format("getFilenameByRegex: Failed to get filename: {}",
-                        e.what())
-                .c_str());
+        lg2::error("getFilenameByRegex: Failed to get filename: {ERROR}",
+                   "ERROR", e.what());
     }
 
     // Return empty path
diff --git a/occ_errors.cpp b/occ_errors.cpp
index bfff111..c764c6f 100644
--- a/occ_errors.cpp
+++ b/occ_errors.cpp
@@ -8,10 +8,10 @@
 #include <org/open_power/OCC/Device/error.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <phosphor-logging/log.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
-#include <format>
 namespace open_power
 {
 namespace occ
@@ -31,10 +31,8 @@
     const int open_errno = errno;
     if (fd < 0)
     {
-        log<level::ERR>(
-            std::format("Error::openFile: open of {} failed (errno={})",
-                        file.c_str(), open_errno)
-                .c_str());
+        lg2::error("Error::openFile: open of {FILE} failed (errno={ERR})",
+                   "FILE", file.c_str(), "ERR", open_errno);
         elog<OpenFailure>(phosphor::logging::org::open_power::OCC::Device::
                               OpenFailure::CALLOUT_ERRNO(open_errno),
                           phosphor::logging::org::open_power::OCC::Device::
@@ -52,8 +50,8 @@
 
     if (r < 0)
     {
-        log<level::ERR>("Failed to register callback handler",
-                        entry("ERROR=%s", strerror(-r)));
+        lg2::error("Failed to register callback handler: error={ERR}", "ERR",
+                   strerror(-r));
         elog<InternalFailure>();
     }
 }
@@ -172,7 +170,7 @@
     auto r = lseek(fd, 0, SEEK_SET);
     if (r < 0)
     {
-        log<level::ERR>("Failure seeking error file to START");
+        lg2::error("Failure seeking error file to START");
         elog<ConfigFailure>(
             phosphor::logging::org::open_power::OCC::Device::ConfigFailure::
                 CALLOUT_ERRNO(errno),
diff --git a/occ_ffdc.cpp b/occ_ffdc.cpp
index da3df79..763660f 100644
--- a/occ_ffdc.cpp
+++ b/occ_ffdc.cpp
@@ -12,12 +12,11 @@
 #include <org/open_power/OCC/Device/error.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <phosphor-logging/log.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/Logging/Create/server.hpp>
 
-#include <format>
-
 namespace open_power
 {
 namespace occ
@@ -43,10 +42,8 @@
         uint8_t, uint8_t, sdbusplus::message::unix_fd>>
         pelFFDCInfo;
 
-    log<level::INFO>(
-        std::format("Creating PEL for OCC{} with SBE FFDC: {} - SRC6: 0x{:08X}",
-                    src6 >> 16, path, src6)
-            .c_str());
+    lg2::info("Creating PEL for OCC{INST} with SBE FFDC: {PATH} - SRC6: {SRC}",
+              "INST", src6 >> 16, "PATH", path, "SRC", lg2::hex, src6);
 
     if (fd > 0)
     {
@@ -92,8 +89,7 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format("Failed to create PEL: {}", e.what()).c_str());
+        lg2::error("Failed to create PEL: {ERR}", "ERR", e.what());
     }
 
     return plid;
@@ -118,9 +114,8 @@
 
     additionalData.emplace("OCC", std::to_string(instance));
 
-    log<level::INFO>(
-        std::format("Creating OCC Reset PEL for OCC{}: {}", instance, path)
-            .c_str());
+    lg2::info("Creating OCC Reset PEL for OCC{INST}: {PATH}", "INST", instance,
+              "PATH", path);
 
     auto& bus = utils::getBus();
 
@@ -150,9 +145,7 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format("Failed to create OCC Reset PEL: {}", e.what())
-                .c_str());
+        lg2::error("Failed to create OCC Reset PEL: {ERR}", "ERR", e.what());
     }
 }
 
@@ -200,7 +193,7 @@
         tfd = mkostemp(templateString.data(), O_RDWR);
         if (tfd < 0)
         {
-            log<level::ERR>("Couldn't create temporary FFDC file");
+            lg2::error("Couldn't create temporary FFDC file");
         }
         else
         {
@@ -215,7 +208,7 @@
                     fs::remove(temporaryFiles.back().first);
                     temporaryFiles.pop_back();
                     tfd = -1;
-                    log<level::ERR>("Couldn't write temporary FFDC file");
+                    lg2::error("Couldn't write temporary FFDC file");
                     break;
                 }
                 if (!r)
@@ -238,20 +231,15 @@
     auto journalFile = makeJsonFFDCFile(getJournalEntries(lines, executable));
     if (journalFile && journalFile->fd() != -1)
     {
-        log<level::DEBUG>(
-            std::format(
-                "addJournalEntries: Added up to {} journal entries for {}",
-                lines, executable)
-                .c_str());
+        lg2::debug(
+            "addJournalEntries: Added up to {NUM} journal entries for {APP}",
+            "NUM", lines, "APP", executable);
         fileList.emplace_back(FFDCFormat::JSON, 0x01, 0x01, journalFile->fd());
     }
     else
     {
-        log<level::ERR>(
-            std::format(
-                "addJournalEntries: Failed to add journal entries for {}",
-                executable)
-                .c_str());
+        lg2::error("addJournalEntries: Failed to add journal entries for {APP}",
+                   "APP", executable);
     }
     return journalFile;
 }
@@ -274,20 +262,16 @@
         else
         {
             auto e = errno;
-            log<level::ERR>(
-                std::format(
-                    "makeJsonFFDCFile: Failed call to write JSON FFDC file, errno={}",
-                    e)
-                    .c_str());
+            lg2::error(
+                "makeJsonFFDCFile: Failed call to write JSON FFDC file, errno={ERR}",
+                "ERR", e);
         }
     }
     else
     {
         auto e = errno;
-        log<level::ERR>(
-            std::format("makeJsonFFDCFile: Failed called to mkostemp, errno={}",
-                        e)
-                .c_str());
+        lg2::error("makeJsonFFDCFile: Failed called to mkostemp, errno={ERR}",
+                   "ERR", e);
     }
     return nullptr;
 }
@@ -428,10 +412,8 @@
     if (_fd() == -1)
     {
         auto e = errno;
-        log<level::ERR>(
-            std::format("FFDCFile: Could not open FFDC file {}. errno {}",
-                        _name.string(), e)
-                .c_str());
+        lg2::error("FFDCFile: Could not open FFDC file {FILE}. errno {ERR}",
+                   "FILE", _name.string(), "ERR", e);
     }
 }
 
diff --git a/occ_manager.cpp b/occ_manager.cpp
index 7823111..62a2b38 100644
--- a/occ_manager.cpp
+++ b/occ_manager.cpp
@@ -8,7 +8,7 @@
 #include "utils.hpp"
 
 #include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 #include <chrono>
@@ -97,11 +97,9 @@
                 // a chance to settle.
                 prevOCCSearch = occs;
 
-                log<level::INFO>(
-                    std::format(
-                        "Manager::findAndCreateObjects(): Waiting for OCCs (currently {})",
-                        occs.size())
-                        .c_str());
+                lg2::info(
+                    "Manager::findAndCreateObjects(): Waiting for OCCs (currently {QTY})",
+                    "QTY", occs.size());
 
                 discoverTimer->restartOnce(10s);
             }
@@ -112,11 +110,9 @@
                 // createObjects requires OCC0 first.
                 std::sort(occs.begin(), occs.end());
 
-                log<level::INFO>(
-                    std::format(
-                        "Manager::findAndCreateObjects(): Creating {} OCC Status Objects",
-                        occs.size())
-                        .c_str());
+                lg2::info(
+                    "Manager::findAndCreateObjects(): Creating {QTY} OCC Status Objects",
+                    "QTY", occs.size());
                 for (auto id : occs)
                 {
                     createObjects(std::string(OCC_NAME) + std::to_string(id));
@@ -139,7 +135,7 @@
             {
                 if (tracedHostWait)
                 {
-                    log<level::INFO>(
+                    lg2::info(
                         "Manager::findAndCreateObjects(): Host is running");
                     tracedHostWait = false;
                 }
@@ -149,7 +145,7 @@
             {
                 if (!tracedHostWait)
                 {
-                    log<level::INFO>(
+                    lg2::info(
                         "Manager::findAndCreateObjects(): Waiting for host to start");
                     tracedHostWait = true;
                 }
@@ -159,8 +155,7 @@
                 {
                     // Host is no longer running, disable throttle timer and
                     // make sure traces are not throttled
-                    log<level::INFO>(
-                        "findAndCreateObjects(): disabling sensor timer");
+                    lg2::info("findAndCreateObjects(): disabling sensor timer");
                     throttlePldmTraceTimer->setEnabled(false);
                     pldmHandle->setTraceThrottle(false);
                 }
@@ -170,11 +165,9 @@
     }
     else
     {
-        log<level::INFO>(
-            std::format(
-                "Manager::findAndCreateObjects(): Waiting for {} to complete...",
-                HOST_ON_FILE)
-                .c_str());
+        lg2::info(
+            "Manager::findAndCreateObjects(): Waiting for {FILE} to complete...",
+            "FILE", HOST_ON_FILE);
         discoverTimer->restartOnce(10s);
     }
 #endif
@@ -193,7 +186,7 @@
         if (waitingForHost)
         {
             waitingForHost = false;
-            log<level::INFO>("checkAllActiveSensors(): Host is now running");
+            lg2::info("checkAllActiveSensors(): Host is now running");
         }
 
         // Start with the assumption that all are available
@@ -208,11 +201,9 @@
                 if (match != queuedActiveState.end())
                 {
                     queuedActiveState.erase(match);
-                    log<level::INFO>(
-                        std::format(
-                            "checkAllActiveSensors(): OCC{} is ACTIVE (queued)",
-                            instance)
-                            .c_str());
+                    lg2::info(
+                        "checkAllActiveSensors(): OCC{INST} is ACTIVE (queued)",
+                        "INST", instance);
                     obj->occActive(true);
                 }
                 else
@@ -220,11 +211,9 @@
                     allActiveSensorAvailable = false;
                     if (!tracedSensorWait)
                     {
-                        log<level::INFO>(
-                            std::format(
-                                "checkAllActiveSensors(): Waiting on OCC{} Active sensor",
-                                instance)
-                                .c_str());
+                        lg2::info(
+                            "checkAllActiveSensors(): Waiting on OCC{INST} Active sensor",
+                            "INST", instance);
                         tracedSensorWait = true;
 #ifdef PLDM
                         // Make sure PLDM traces are not throttled
@@ -252,15 +241,13 @@
         if (!waitingForHost)
         {
             waitingForHost = true;
-            log<level::INFO>(
-                "checkAllActiveSensors(): Waiting for host to start");
+            lg2::info("checkAllActiveSensors(): Waiting for host to start");
 #ifdef PLDM
             if (throttlePldmTraceTimer->isEnabled())
             {
                 // Host is no longer running, disable throttle timer and
                 // make sure traces are not throttled
-                log<level::INFO>(
-                    "checkAllActiveSensors(): disabling sensor timer");
+                lg2::info("checkAllActiveSensors(): disabling sensor timer");
                 throttlePldmTraceTimer->setEnabled(false);
                 pldmHandle->setTraceThrottle(false);
             }
@@ -285,7 +272,7 @@
 #endif
         if (waitingForAllOccActiveSensors)
         {
-            log<level::INFO>(
+            lg2::info(
                 "checkAllActiveSensors(): OCC Active sensors are available");
             waitingForAllOccActiveSensors = false;
 
@@ -295,7 +282,7 @@
 
                 if (!waitForAllOccsTimer->isEnabled())
                 {
-                    log<level::WARNING>(
+                    lg2::warning(
                         "occsNotAllRunning: Restarting waitForAllOccTimer");
                     // restart occ wait timer to check status after reset
                     // completes
@@ -311,7 +298,7 @@
         // Not all sensors were available, so keep waiting
         if (!tracedSensorWait)
         {
-            log<level::INFO>(
+            lg2::info(
                 "checkAllActiveSensors(): Waiting for OCC Active sensors to become available");
             tracedSensorWait = true;
         }
@@ -387,10 +374,8 @@
 
     if (statusObjects.back()->isMasterOcc())
     {
-        log<level::INFO>(
-            std::format("Manager::createObjects(): OCC{} is the master",
-                        statusObjects.back()->getOccInstanceID())
-                .c_str());
+        lg2::info("Manager::createObjects(): OCC{INST} is the master", "INST",
+                  statusObjects.back()->getOccInstanceID());
         _pollTimer->setEnabled(false);
 
 #ifdef POWER10
@@ -416,19 +401,15 @@
     {
         resetRequired = true;
         resetInstance = instance;
-        log<level::ERR>(
-            std::format(
-                "resetOccRequest: PM Complex reset was requested due to OCC{}",
-                instance)
-                .c_str());
+        lg2::error(
+            "resetOccRequest: PM Complex reset was requested due to OCC{INST}",
+            "INST", instance);
     }
     else if (instance != resetInstance)
     {
-        log<level::WARNING>(
-            std::format(
-                "resetOccRequest: Ignoring PM Complex reset request for OCC{}, because reset already outstanding for OCC{}",
-                instance, resetInstance)
-                .c_str());
+        lg2::warning(
+            "resetOccRequest: Ignoring PM Complex reset request for OCC{INST}, because reset already outstanding for OCC{RINST}",
+            "INST", instance, "RINST", resetInstance);
     }
 }
 
@@ -439,11 +420,9 @@
     {
         resetInProgress = true;
         resetInstance = instance;
-        log<level::ERR>(
-            std::format(
-                "initiateOccRequest: Initiating PM Complex reset due to OCC{}",
-                instance)
-                .c_str());
+        lg2::error(
+            "initiateOccRequest: Initiating PM Complex reset due to OCC{INST}",
+            "INST", instance);
 #ifdef PLDM
         pldmHandle->resetOCC(instance);
 #endif
@@ -451,11 +430,9 @@
     }
     else
     {
-        log<level::WARNING>(
-            std::format(
-                "initiateOccRequest: Ignoring PM Complex reset request for OCC{}, because reset already in process for OCC{}",
-                instance, resetInstance)
-                .c_str());
+        lg2::warning(
+            "initiateOccRequest: Ignoring PM Complex reset request for OCC{INST}, because reset already in process for OCC{RINST}",
+            "INST", instance, "RINST", resetInstance);
     }
 }
 
@@ -465,11 +442,9 @@
     {
         if (resetInProgress)
         {
-            log<level::INFO>(
-                std::format(
-                    "statusCallBack: Ignoring OCC{} activate because a reset has been initiated due to OCC{}",
-                    instance, resetInstance)
-                    .c_str());
+            lg2::info(
+                "statusCallBack: Ignoring OCC{INST} activate because a reset has been initiated due to OCC{INST}",
+                "INST", instance, "RINST", resetInstance);
             return;
         }
 
@@ -501,7 +476,7 @@
 
                 if (!waitForAllOccsTimer->isEnabled())
                 {
-                    log<level::WARNING>(
+                    lg2::warning(
                         "occsNotAllRunning: Restarting waitForAllOccTimer");
                     // restart occ wait timer
                     waitForAllOccsTimer->restartOnce(60s);
@@ -521,10 +496,8 @@
         // Start poll timer if not already started
         if (!_pollTimer->isEnabled())
         {
-            log<level::INFO>(
-                std::format("Manager: OCCs will be polled every {} seconds",
-                            pollInterval)
-                    .c_str());
+            lg2::info("Manager: OCCs will be polled every {TIME} seconds",
+                      "TIME", pollInterval);
 
             // Send poll and start OCC poll timer
             pollerTimerExpired();
@@ -539,10 +512,8 @@
         }
         else
         {
-            log<level::INFO>(
-                std::format("OCC{} disabled, but currently no active OCCs",
-                            instance)
-                    .c_str());
+            lg2::info("OCC{INST} disabled, but currently no active OCCs",
+                      "INST", instance);
         }
 
         if (activeCount == 0)
@@ -553,11 +524,9 @@
             {
                 // All OCC active sensors are clear (reset should be in
                 // progress)
-                log<level::INFO>(
-                    std::format(
-                        "statusCallBack: Clearing resetInProgress (activeCount={}, OCC{}, status={})",
-                        activeCount, instance, status)
-                        .c_str());
+                lg2::info(
+                    "statusCallBack: Clearing resetInProgress (activeCount={COUNT}, OCC{INST}, status={STATUS})",
+                    "COUNT", activeCount, "INST", instance, "STATUS", status);
                 resetInProgress = false;
                 resetInstance = 255;
             }
@@ -565,7 +534,7 @@
             // Stop OCC poll timer
             if (_pollTimer->isEnabled())
             {
-                log<level::INFO>(
+                lg2::info(
                     "Manager::statusCallBack(): OCCs are not running, stopping poll timer");
                 _pollTimer->setEnabled(false);
             }
@@ -580,11 +549,9 @@
         }
         else if (resetInProgress)
         {
-            log<level::INFO>(
-                std::format(
-                    "statusCallBack: Skipping clear of resetInProgress (activeCount={}, OCC{}, status={})",
-                    activeCount, instance, status)
-                    .c_str());
+            lg2::info(
+                "statusCallBack: Skipping clear of resetInProgress (activeCount={COUNT}, OCC{INST}, status={STATUS})",
+                "COUNT", activeCount, "INST", instance, "STATUS", status);
         }
 #ifdef READ_OCC_SENSORS
         // Clear OCC sensors
@@ -640,9 +607,8 @@
 
     if (obj != statusObjects.end() && (*obj)->occActive())
     {
-        log<level::INFO>(
-            std::format("SBE timeout, requesting HRESET (OCC{})", instance)
-                .c_str());
+        lg2::info("SBE timeout, requesting HRESET (OCC{INST})", "INST",
+                  instance);
 
         setSBEState(instance, SBE_STATE_NOT_USABLE);
 
@@ -662,15 +628,13 @@
     {
         if (!hostRunning && (status == true))
         {
-            log<level::WARNING>(
-                std::format(
-                    "updateOCCActive: Host is not running yet (OCC{} active={}), clearing sensor received",
-                    instance, status)
-                    .c_str());
+            lg2::warning(
+                "updateOCCActive: Host is not running yet (OCC{INST} active={STAT}), clearing sensor received",
+                "INST", instance, "STAT", status);
             (*obj)->setPldmSensorReceived(false);
             if (!waitingForAllOccActiveSensors)
             {
-                log<level::INFO>(
+                lg2::info(
                     "updateOCCActive: Waiting for Host and all OCC Active Sensors");
                 waitingForAllOccActiveSensors = true;
             }
@@ -689,21 +653,17 @@
     {
         if (hostRunning)
         {
-            log<level::WARNING>(
-                std::format(
-                    "updateOCCActive: No status object to update for OCC{} (active={})",
-                    instance, status)
-                    .c_str());
+            lg2::warning(
+                "updateOCCActive: No status object to update for OCC{INST} (active={STAT})",
+                "INST", instance, "STAT", status);
         }
         else
         {
             if (status == true)
             {
-                log<level::WARNING>(
-                    std::format(
-                        "updateOCCActive: No status objects and Host is not running yet (OCC{} active={})",
-                        instance, status)
-                        .c_str());
+                lg2::warning(
+                    "updateOCCActive: No status objects and Host is not running yet (OCC{INST} active={STAT})",
+                    "INST", instance, "STAT", status);
             }
         }
         if (status == true)
@@ -741,8 +701,7 @@
 {
     if (success)
     {
-        log<level::INFO>(
-            std::format("HRESET succeeded (OCC{})", instance).c_str());
+        lg2::info("HRESET succeeded (OCC{INST})", "INST", instance);
 
         setSBEState(instance, SBE_STATE_BOOTED);
 
@@ -753,9 +712,8 @@
 
     if (sbeCanDump(instance))
     {
-        log<level::INFO>(
-            std::format("HRESET failed (OCC{}), triggering SBE dump", instance)
-                .c_str());
+        lg2::info("HRESET failed (OCC{INST}), triggering SBE dump", "INST",
+                  instance);
 
         auto& bus = utils::getBus();
         uint32_t src6 = instance << 16;
@@ -793,17 +751,17 @@
                 "xyz.openbmc_project.Dump.Create.Error.Disabled";
             if (e.name() == ERROR_DUMP_DISABLED)
             {
-                log<level::INFO>("Dump is disabled, skipping");
+                lg2::info("Dump is disabled, skipping");
             }
             else
             {
-                log<level::ERR>("Dump failed");
+                lg2::error("Dump failed");
             }
         }
     }
 
     // SBE Reset failed, try PM Complex reset
-    log<level::ERR>("sbeHRESETResult: Forcing PM Complex reset");
+    lg2::error("sbeHRESETResult: Forcing PM Complex reset");
     resetOccRequest(instance);
 }
 
@@ -831,7 +789,7 @@
     }
     catch (openpower::phal::exception::SbeError& e)
     {
-        log<level::INFO>("Failed to query SBE state");
+        lg2::info("Failed to query SBE state");
     }
 
     // allow the dump in the error case
@@ -853,8 +811,7 @@
     }
     catch (const openpower::phal::exception::SbeError& e)
     {
-        log<level::ERR>(
-            std::format("Failed to set SBE state: {}", e.what()).c_str());
+        lg2::error("Failed to set SBE state: {ERROR}", "ERROR", e.what());
     }
 }
 
@@ -869,7 +826,7 @@
         }
         catch (const openpower::phal::exception::PdbgError& e)
         {
-            log<level::ERR>("pdbg initialization failed");
+            lg2::error("pdbg initialization failed");
             return nullptr;
         }
     }
@@ -883,7 +840,7 @@
         }
     }
 
-    log<level::ERR>("Failed to get pdbg target");
+    lg2::error("Failed to get pdbg target");
     return nullptr;
 }
 #endif
@@ -892,20 +849,19 @@
 {
     if (!_pollTimer)
     {
-        log<level::ERR>("pollerTimerExpired() ERROR: Timer not defined");
+        lg2::error("pollerTimerExpired() ERROR: Timer not defined");
         return;
     }
 
 #ifdef POWER10
     if (resetRequired)
     {
-        log<level::ERR>("pollerTimerExpired() - Initiating PM Complex reset");
+        lg2::error("pollerTimerExpired() - Initiating PM Complex reset");
         initiateOccRequest(resetInstance);
 
         if (!waitForAllOccsTimer->isEnabled())
         {
-            log<level::WARNING>(
-                "pollerTimerExpired: Restarting waitForAllOccTimer");
+            lg2::warning("pollerTimerExpired: Restarting waitForAllOccTimer");
             // restart occ wait timer
             waitForAllOccsTimer->restartOnce(60s);
         }
@@ -942,10 +898,8 @@
     else
     {
         // No OCCs running, so poll timer will not be restarted
-        log<level::INFO>(
-            std::format(
-                "Manager::pollerTimerExpired: poll timer will not be restarted")
-                .c_str());
+        lg2::info(
+            "Manager::pollerTimerExpired: poll timer will not be restarted");
     }
 }
 
@@ -974,10 +928,9 @@
         }
         catch (const std::system_error& e)
         {
-            log<level::DEBUG>(
-                std::format("readTempSensors: Failed reading {}, errno = {}",
-                            file.path().string(), e.code().value())
-                    .c_str());
+            lg2::debug(
+                "readTempSensors: Failed reading {PATH}, errno = {ERROR}",
+                "PATH", file.path().string(), "ERROR", e.code().value());
             continue;
         }
 
@@ -992,10 +945,10 @@
         }
         catch (const std::system_error& e)
         {
-            log<level::DEBUG>(
-                std::format("readTempSensors: Failed reading {}, errno = {}",
-                            filePathString + fruTypeSuffix, e.code().value())
-                    .c_str());
+            lg2::debug(
+                "readTempSensors: Failed reading {PATH}, errno = {ERROR}",
+                "PATH", filePathString + fruTypeSuffix, "ERROR",
+                e.code().value());
             continue;
         }
 
@@ -1032,11 +985,9 @@
                 auto iter = dimmTempSensorName.find(fruTypeValue);
                 if (iter == dimmTempSensorName.end())
                 {
-                    log<level::ERR>(
-                        std::format(
-                            "readTempSensors: Fru type error! fruTypeValue = {}) ",
-                            fruTypeValue)
-                            .c_str());
+                    lg2::error(
+                        "readTempSensors: Fru type error! fruTypeValue = {FRU}) ",
+                        "FRU", fruTypeValue);
                     continue;
                 }
 
@@ -1087,11 +1038,10 @@
             }
             catch (const std::system_error& e)
             {
-                log<level::DEBUG>(
-                    std::format(
-                        "readTempSensors: Failed reading {}, errno = {}",
-                        filePathString + maxSuffix, e.code().value())
-                        .c_str());
+                lg2::debug(
+                    "readTempSensors: Failed reading {PATH}, errno = {ERROR}",
+                    "PATH", filePathString + maxSuffix, "ERROR",
+                    e.code().value());
             }
         }
 
@@ -1102,10 +1052,10 @@
         }
         catch (const std::system_error& e)
         {
-            log<level::DEBUG>(
-                std::format("readTempSensors: Failed reading {}, errno = {}",
-                            filePathString + faultSuffix, e.code().value())
-                    .c_str());
+            lg2::debug(
+                "readTempSensors: Failed reading {PATH}, errno = {ERROR}",
+                "PATH", filePathString + faultSuffix, "ERROR",
+                e.code().value());
             continue;
         }
 
@@ -1124,11 +1074,10 @@
             }
             catch (const std::system_error& e)
             {
-                log<level::DEBUG>(
-                    std::format(
-                        "readTempSensors: Failed reading {}, errno = {}",
-                        filePathString + inputSuffix, e.code().value())
-                        .c_str());
+                lg2::debug(
+                    "readTempSensors: Failed reading {PATH}, errno = {ERROR}",
+                    "PATH", filePathString + inputSuffix, "ERROR",
+                    e.code().value());
 
                 // if errno == EAGAIN(Resource temporarily unavailable) then set
                 // temp to 0, to avoid using old temp, and affecting FAN
@@ -1238,10 +1187,9 @@
         }
         catch (const std::system_error& e)
         {
-            log<level::DEBUG>(
-                std::format("readPowerSensors: Failed reading {}, errno = {}",
-                            file.path().string(), e.code().value())
-                    .c_str());
+            lg2::debug(
+                "readPowerSensors: Failed reading {PATH}, errno = {ERROR}",
+                "PATH", file.path().string(), "ERROR", e.code().value());
             continue;
         }
 
@@ -1272,10 +1220,10 @@
         }
         catch (const std::system_error& e)
         {
-            log<level::DEBUG>(
-                std::format("readPowerSensors: Failed reading {}, errno = {}",
-                            filePathString + inputSuffix, e.code().value())
-                    .c_str());
+            lg2::debug(
+                "readPowerSensors: Failed reading {PATH}, errno = {ERROR}",
+                "PATH", filePathString + inputSuffix, "ERROR",
+                e.code().value());
             continue;
         }
 
@@ -1360,11 +1308,9 @@
     {
         if (!tracedError[id])
         {
-            log<level::ERR>(
-                std::format(
-                    "Manager::getSensorValues: OCC{} sensor path missing: {}",
-                    id, sensorPath.c_str())
-                    .c_str());
+            lg2::error(
+                "Manager::getSensorValues: OCC{INST} sensor path missing: {PATH}",
+                "INST", id, "PATH", sensorPath);
             tracedError[id] = true;
         }
     }
@@ -1395,9 +1341,8 @@
                 // Round to nearest meter
                 altitude = uint16_t(sensorVal + 0.5);
             }
-            log<level::DEBUG>(std::format("readAltitude: sensor={} ({}m)",
-                                          sensorVal, altitude)
-                                  .c_str());
+            lg2::debug("readAltitude: sensor={VALUE} ({ALT}m)", "VALUE",
+                       sensorVal, "ALT", altitude);
             traceAltitudeErr = true;
         }
         else
@@ -1405,9 +1350,7 @@
             if (traceAltitudeErr)
             {
                 traceAltitudeErr = false;
-                log<level::DEBUG>(
-                    std::format("Invalid altitude value: {}", sensorVal)
-                        .c_str());
+                lg2::debug("Invalid altitude value: {ALT}", "ALT", sensorVal);
             }
         }
     }
@@ -1416,8 +1359,7 @@
         if (traceAltitudeErr)
         {
             traceAltitudeErr = false;
-            log<level::INFO>(
-                std::format("Unable to read Altitude: {}", e.what()).c_str());
+            lg2::info("Unable to read Altitude: {ERROR}", "ERROR", e.what());
         }
         altitude = 0xFFFF; // not available
     }
@@ -1435,7 +1377,7 @@
     auto valPropMap = msgData.find(AMBIENT_PROP);
     if (valPropMap == msgData.end())
     {
-        log<level::DEBUG>("ambientCallback: Unknown ambient property changed");
+        lg2::debug("ambientCallback: Unknown ambient property changed");
         return;
     }
     currentTemp = std::get<double>(valPropMap->second);
@@ -1459,10 +1401,8 @@
     // If ambient changes, notify OCCs
     if (truncatedTemp != ambient)
     {
-        log<level::DEBUG>(
-            std::format("ambientCallback: Ambient change from {} to {}C",
-                        ambient, currentTemp)
-                .c_str());
+        lg2::debug("ambientCallback: Ambient change from {OLD} to {NEW}C",
+                   "OLD", ambient, "NEW", currentTemp);
 
         ambient = truncatedTemp;
         if (altitude == 0xFFFF)
@@ -1471,10 +1411,8 @@
             readAltitude();
         }
 
-        log<level::DEBUG>(
-            std::format("ambientCallback: Ambient: {}C, altitude: {}m", ambient,
-                        altitude)
-                .c_str());
+        lg2::debug("ambientCallback: Ambient: {TEMP}C, altitude: {ALT}m",
+                   "TEMP", ambient, "ALT", altitude);
 #ifdef POWER10
         // Send ambient and altitude to all OCCs
         for (auto& obj : statusObjects)
@@ -1509,18 +1447,16 @@
 {
     if (resetInProgress)
     {
-        log<level::WARNING>(
+        lg2::warning(
             "occsNotAllRunning: Ignoring waitForAllOccsTimer because reset is in progress");
         return;
     }
     if (activeCount != statusObjects.size())
     {
         // Not all OCCs went active
-        log<level::WARNING>(
-            std::format(
-                "occsNotAllRunning: Active OCC count ({}) does not match expected count ({})",
-                activeCount, statusObjects.size())
-                .c_str());
+        lg2::warning(
+            "occsNotAllRunning: Active OCC count ({COUNT}) does not match expected count ({EXP})",
+            "COUNT", activeCount, "EXP", statusObjects.size());
         // Procs may be garded, so may be expected
     }
 
@@ -1530,8 +1466,7 @@
 
         if (!waitForAllOccsTimer->isEnabled())
         {
-            log<level::WARNING>(
-                "occsNotAllRunning: Restarting waitForAllOccTimer");
+            lg2::warning("occsNotAllRunning: Restarting waitForAllOccTimer");
             // restart occ wait timer
             waitForAllOccsTimer->restartOnce(60s);
         }
@@ -1561,7 +1496,7 @@
         }
         else
         {
-            log<level::ERR>(
+            lg2::error(
                 "throttlePldmTraceExpired(): OCC active sensors still not available!");
             // Create PEL
             createPldmSensorPEL();
@@ -1571,7 +1506,7 @@
     {
         // Make sure traces are not throttled
         pldmHandle->setTraceThrottle(false);
-        log<level::INFO>(
+        lg2::info(
             "throttlePldmTraceExpired(): host it not running ignoring sensor timer");
     }
 }
@@ -1583,10 +1518,8 @@
 
     additionalData.emplace("_PID", std::to_string(getpid()));
 
-    log<level::INFO>(
-        std::format(
-            "createPldmSensorPEL(): Unable to find PLDM sensors for the OCCs")
-            .c_str());
+    lg2::info(
+        "createPldmSensorPEL(): Unable to find PLDM sensors for the OCCs");
 
     auto& bus = utils::getBus();
 
@@ -1617,10 +1550,8 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format("Failed to create MISSING_OCC_SENSORS PEL: {}",
-                        e.what())
-                .c_str());
+        lg2::error("Failed to create MISSING_OCC_SENSORS PEL: {ERROR}", "ERROR",
+                   e.what());
     }
 }
 #endif // PLDM
@@ -1643,11 +1574,8 @@
                 if (match != queuedActiveState.end())
                 {
                     queuedActiveState.erase(match);
-                    log<level::INFO>(
-                        std::format(
-                            "validateOccMaster: OCC{} is ACTIVE (queued)",
-                            instance)
-                            .c_str());
+                    lg2::info("validateOccMaster: OCC{INST} is ACTIVE (queued)",
+                              "INST", instance);
                     obj->occActive(true);
                 }
                 else
@@ -1658,21 +1586,17 @@
 #endif
                     if (obj->occActive())
                     {
-                        log<level::INFO>(
-                            std::format(
-                                "validateOccMaster: OCC{} is ACTIVE after reading sensor",
-                                instance)
-                                .c_str());
+                        lg2::info(
+                            "validateOccMaster: OCC{INST} is ACTIVE after reading sensor",
+                            "INST", instance);
                     }
                 }
             }
             else
             {
-                log<level::WARNING>(
-                    std::format(
-                        "validateOccMaster: HOST is not running (OCC{})",
-                        instance)
-                        .c_str());
+                lg2::warning(
+                    "validateOccMaster: HOST is not running (OCC{INST})",
+                    "INST", instance);
                 return;
             }
         }
@@ -1688,11 +1612,9 @@
             }
             else
             {
-                log<level::ERR>(
-                    std::format(
-                        "validateOccMaster: Multiple OCC masters! ({} and {})",
-                        masterInstance, instance)
-                        .c_str());
+                lg2::error(
+                    "validateOccMaster: Multiple OCC masters! ({MAST1} and {MAST2})",
+                    "MAST1", masterInstance, "MAST2", instance);
                 // request reset
                 obj->deviceError(Error::Descriptor(PRESENCE_ERROR_PATH));
             }
@@ -1701,20 +1623,16 @@
 
     if (masterInstance < 0)
     {
-        log<level::ERR>(
-            std::format("validateOccMaster: Master OCC not found! (of {} OCCs)",
-                        statusObjects.size())
-                .c_str());
+        lg2::error("validateOccMaster: Master OCC not found! (of {NUM} OCCs)",
+                   "NUM", statusObjects.size());
         // request reset
         statusObjects.front()->deviceError(
             Error::Descriptor(PRESENCE_ERROR_PATH));
     }
     else
     {
-        log<level::INFO>(
-            std::format("validateOccMaster: OCC{} is master of {} OCCs",
-                        masterInstance, activeCount)
-                .c_str());
+        lg2::info("validateOccMaster: OCC{INST} is master of {COUNT} OCCs",
+                  "INST", masterInstance, "COUNT", activeCount);
 #ifdef POWER10
         pmode->updateDbusSafeMode(false);
 #endif
diff --git a/occ_pass_through.cpp b/occ_pass_through.cpp
index 8567784..61e9ad3 100644
--- a/occ_pass_through.cpp
+++ b/occ_pass_through.cpp
@@ -7,12 +7,9 @@
 #include <unistd.h>
 
 #include <org/open_power/OCC/Device/error.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <algorithm>
-#include <format>
 #include <memory>
 #include <string>
 
@@ -75,11 +72,9 @@
 
     if (!occActive)
     {
-        log<level::ERR>(
-            std::format(
-                "PassThrough::send() - OCC{} not active, command not sent",
-                occInstance)
-                .c_str());
+        lg2::error(
+            "PassThrough::send() - OCC{INST} not active, command not sent",
+            "INST", occInstance);
         return response;
     }
 
@@ -101,42 +96,35 @@
                 dataString += "...";
             }
         }
-        log<level::INFO>(
-            std::format(
-                "PassThrough::send() Sending 0x{:02X} command to OCC{} (data len={}, data={})",
-                command.front(), occInstance, dataLen, dataString)
-                .c_str());
+        lg2::info(
+            "PassThrough::send() Sending {CMD} command to OCC{INST} (data len={LEN}, data={DATA})",
+            "CMD", lg2::hex, command.front(), "INST", occInstance, "LEN",
+            dataLen, "DATA", dataString);
     }
     else
     {
-        log<level::INFO>(
-            std::format("PassThrough::send() Sending 0x{:02X} command to OCC{}",
-                        command.front(), occInstance)
-                .c_str());
+        lg2::info("PassThrough::send() Sending {CMD} command to OCC{INST}",
+                  "CMD", command.front(), "INST", occInstance);
     }
     CmdStatus status = occCmd.send(command, response);
     if (status == CmdStatus::SUCCESS)
     {
         if (response.size() >= 5)
         {
-            log<level::DEBUG>(
-                std::format("PassThrough::send() response had {} bytes",
-                            response.size())
-                    .c_str());
+            lg2::debug("PassThrough::send() response had {LEN} bytes", "LEN",
+                       response.size());
         }
         else
         {
-            log<level::ERR>("PassThrough::send() Invalid OCC response");
+            lg2::error("PassThrough::send() Invalid OCC response");
             dump_hex(response);
         }
     }
     else
     {
-        log<level::ERR>(
-            std::format(
-                "PassThrough::send(): OCC command failed with status {}",
-                uint32_t(status))
-                .c_str());
+        lg2::error(
+            "PassThrough::send(): OCC command failed with status {STATUS}",
+            "STATUS", status);
     }
 
     return response;
@@ -149,42 +137,34 @@
 
     if (!pmode)
     {
-        log<level::ERR>("PassThrough::setMode: PowerMode is not defined!");
+        lg2::error("PassThrough::setMode: PowerMode is not defined!");
         return false;
     }
 
     if (!pmode->isValidMode(SysPwrMode(mode)))
     {
-        log<level::ERR>(
-            std::format(
-                "PassThrough::setMode() Unsupported mode {} requested (0x{:04X})",
-                newMode, modeData)
-                .c_str());
+        lg2::error(
+            "PassThrough::setMode() Unsupported mode {MODE} requested ({DATA})",
+            "MODE", newMode, "DATA", modeData);
         return false;
     }
 
     if (((newMode == SysPwrMode::FFO) || (newMode == SysPwrMode::SFP)) &&
         (modeData == 0))
     {
-        log<level::ERR>(
-            std::format(
-                "PassThrough::setMode() Mode {} requires non-zero frequency point.",
-                newMode)
-                .c_str());
+        lg2::error(
+            "PassThrough::setMode() Mode {MODE} requires non-zero frequency point.",
+            "MODE", newMode);
         return false;
     }
 
-    log<level::INFO>(
-        std::format("PassThrough::setMode() Setting Power Mode {} (data: {})",
-                    newMode, modeData)
-            .c_str());
+    lg2::info("PassThrough::setMode() Setting Power Mode {MODE} (data: {DATA})",
+              "MODE", uint8_t(newMode), "DATA", modeData);
     return pmode->setMode(newMode, modeData);
 #else
-    log<level::DEBUG>(
-        std::format(
-            "PassThrough::setMode() No support to setting Power Mode {} (data: {})",
-            mode, modeData)
-            .c_str());
+    lg2::debug(
+        "PassThrough::setMode() No support to setting Power Mode {MODE} (data: {DATA})",
+        "MODE", mode, "DATA", modeData);
     return false;
 #endif
 }
diff --git a/occ_presence.cpp b/occ_presence.cpp
index 73ccf66..b7d4276 100644
--- a/occ_presence.cpp
+++ b/occ_presence.cpp
@@ -10,7 +10,7 @@
 #include <org/open_power/OCC/Device/error.hpp>
 #include <phosphor-logging/elog-errors.hpp>
 #include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 
 namespace open_power
@@ -46,9 +46,8 @@
     auto occsPresent = std::stoi(data, nullptr, 0);
     if (manager.getNumOCCs() != occsPresent)
     {
-        log<level::ERR>(std::format("OCC presence mismatch - BMC: {}, OCC: {}",
-                                    manager.getNumOCCs(), occsPresent)
-                            .c_str());
+        lg2::error("OCC presence mismatch - BMC: {BNUM}, OCC: {ONUM}", "BNUM",
+                   manager.getNumOCCs(), "ONUM", occsPresent);
         if (callBack)
         {
             callBack(occsPresent);
diff --git a/occ_status.cpp b/occ_status.cpp
index 4b6e276..c664d11 100644
--- a/occ_status.cpp
+++ b/occ_status.cpp
@@ -5,10 +5,9 @@
 #include "powermode.hpp"
 #include "utils.hpp"
 
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 
 #include <filesystem>
-#include <format>
 
 namespace open_power
 {
@@ -25,9 +24,8 @@
 {
     if (value != this->occActive())
     {
-        log<level::INFO>(std::format("Status::occActive OCC{} changed to {}",
-                                     instance, value)
-                             .c_str());
+        lg2::info("Status::occActive OCC{INST} changed to {STATE}", "INST",
+                  instance, "STATE", value);
         if (value)
         {
             // Clear prior throttle reason (before setting device active)
@@ -48,11 +46,9 @@
             {
                 // Failed to add watch for throttle events, request reset to try
                 // to recover comm
-                log<level::ERR>(
-                    std::format(
-                        "Status::occActive: Unable to add error watch(s) for OCC{} watch: {}",
-                        instance, e.what())
-                        .c_str());
+                lg2::error(
+                    "Status::occActive: Unable to add error watch(s) for OCC{INST} watch: {ERROR}",
+                    "INST", instance, "ERROR", e.what());
                 deviceError(Error::Descriptor(OCC_COMM_ERROR_PATH));
                 return Base::Status::occActive(false);
             }
@@ -127,11 +123,9 @@
         {
             // Failed to add watch for throttle events, request reset to try to
             // recover comm
-            log<level::ERR>(
-                std::format(
-                    "Status::occActive: Unable to add error watch(s) again for OCC{} watch: {}",
-                    instance, e.what())
-                    .c_str());
+            lg2::error(
+                "Status::occActive: Unable to add error watch(s) again for OCC{INST} watch: {ERROR}",
+                "INST", instance, "ERROR", e.what());
             deviceError(Error::Descriptor(OCC_COMM_ERROR_PATH));
             return Base::Status::occActive(false);
         }
@@ -176,10 +170,8 @@
 // Sends message to host control command handler to reset OCC
 void Status::resetOCC()
 {
-    log<level::INFO>(
-        std::format(">>Status::resetOCC() - requesting reset for OCC{}",
-                    instance)
-            .c_str());
+    lg2::info(">>Status::resetOCC() - requesting reset for OCC{INST}", "INST",
+              instance);
     this->occActive(false);
 #ifdef PLDM
     if (resetCallBack)
@@ -215,9 +207,8 @@
 
     msg.read(cmdCompleted, cmdStatus);
 
-    log<level::DEBUG>("Host control signal values",
-                      entry("COMMAND=%s", cmdCompleted.c_str()),
-                      entry("STATUS=%s", cmdStatus.c_str()));
+    lg2::debug("Host control signal values: command={CMD}, status={STATUS}",
+               "CMD", cmdCompleted, "STATUS", cmdStatus);
 
     if (Control::Host::convertResultFromString(cmdStatus) !=
         Control::Host::Result::Success)
@@ -226,9 +217,9 @@
             Control::Host::Command::OCCReset)
         {
             // Must be a Timeout. Log an Error trace
-            log<level::ERR>(
-                "Error resetting the OCC.", entry("PATH=%s", path.c_str()),
-                entry("SENSORID=0x%X", std::get<0>(sensorMap.at(instance))));
+            lg2::error(
+                "Error resetting the OCC: path={PATH}, sensorid={SENSOR}",
+                "PATH", path, "SENSOR", std::get<0>(sensorMap.at(instance)));
         }
     }
     return;
@@ -258,11 +249,9 @@
     status = pmode->sendModeChange();
     if (status != CmdStatus::SUCCESS)
     {
-        log<level::ERR>(
-            std::format(
-                "Status::occsWentActive: OCC mode change failed with status {}",
-                status)
-                .c_str());
+        lg2::error(
+            "Status::occsWentActive: OCC mode change failed with status {STATUS}",
+            "STATUS", status);
 
         // Disable and reset to try recovering
         deviceError();
@@ -281,10 +270,9 @@
     {
         // Get latest readings from manager
         manager.getAmbientData(ambientValid, ambientTemp, altitude);
-        log<level::DEBUG>(
-            std::format("sendAmbient: valid: {}, Ambient: {}C, altitude: {}m",
-                        ambientValid, ambientTemp, altitude)
-                .c_str());
+        lg2::debug(
+            "sendAmbient: valid: {VALID}, Ambient: {TEMP}C, altitude: {ALT}m",
+            "VALID", ambientValid, "TEMP", ambientTemp, "ALT", altitude);
     }
 
     std::vector<std::uint8_t> cmd, rsp;
@@ -300,10 +288,9 @@
     cmd.push_back(0x00);                    // Reserved (3 bytes)
     cmd.push_back(0x00);
     cmd.push_back(0x00);
-    log<level::DEBUG>(std::format("sendAmbient: SEND_AMBIENT "
-                                  "command to OCC{} ({} bytes)",
-                                  instance, cmd.size())
-                          .c_str());
+    lg2::debug("sendAmbient: SEND_AMBIENT "
+               "command to OCC{INST} ({SIZE} bytes)",
+               "INST", instance, "SIZE", cmd.size());
     status = occCmd.send(cmd, rsp);
     if (status == CmdStatus::SUCCESS)
     {
@@ -311,33 +298,26 @@
         {
             if (RspStatus::SUCCESS != RspStatus(rsp[2]))
             {
-                log<level::ERR>(
-                    std::format(
-                        "sendAmbient: SEND_AMBIENT failed with rspStatus 0x{:02X}",
-                        rsp[2])
-                        .c_str());
+                lg2::error(
+                    "sendAmbient: SEND_AMBIENT failed with rspStatus {STATUS}",
+                    "STATUS", lg2::hex, rsp[2]);
                 dump_hex(rsp);
                 status = CmdStatus::FAILURE;
             }
         }
         else
         {
-            log<level::ERR>(
-                std::format(
-                    "sendAmbient: INVALID SEND_AMBIENT response length:{}",
-                    rsp.size())
-                    .c_str());
+            lg2::error(
+                "sendAmbient: INVALID SEND_AMBIENT response length:{SIZE}",
+                "SIZE", rsp.size());
             dump_hex(rsp);
             status = CmdStatus::FAILURE;
         }
     }
     else
     {
-        log<level::ERR>(
-            std::format(
-                "sendAmbient: SEND_AMBIENT FAILED! with status 0x{:02X}",
-                status)
-                .c_str());
+        lg2::error("sendAmbient: SEND_AMBIENT FAILED! with status {STATUS}",
+                   "STATUS", lg2::hex, uint8_t(status));
 
         if (status == CmdStatus::COMM_FAILURE)
         {
@@ -354,11 +334,9 @@
 {
     if (this->occActive())
     {
-        log<level::INFO>(
-            std::format(
-                "safeStateDelayExpired: OCC{} state missing or not valid, requesting reset",
-                instance)
-                .c_str());
+        lg2::info(
+            "safeStateDelayExpired: OCC{INST} state missing or not valid, requesting reset",
+            "INST", instance);
         // Disable and reset to try recovering
         deviceError(Error::Descriptor(SAFE_ERROR_PATH));
     }
@@ -375,10 +353,9 @@
 
         if (!hwmonPath.empty())
         {
-            log<level::WARNING>(
-                std::format("Status::getHwmonPath(): path no longer exists: {}",
-                            hwmonPath.c_str())
-                    .c_str());
+            lg2::warning(
+                "Status::getHwmonPath(): path no longer exists: {PATH}", "PATH",
+                hwmonPath);
             hwmonPath.clear();
         }
 
@@ -402,11 +379,9 @@
             {
                 if (!tracedFail[instance])
                 {
-                    log<level::ERR>(
-                        std::format(
-                            "Status::getHwmonPath(): Found multiple ({}) hwmon paths!",
-                            numDirs)
-                            .c_str());
+                    lg2::error(
+                        "Status::getHwmonPath(): Found multiple ({NUM}) hwmon paths!",
+                        "NUM", numDirs);
                     tracedFail[instance] = true;
                 }
             }
@@ -415,11 +390,9 @@
         {
             if (!tracedFail[instance])
             {
-                log<level::ERR>(
-                    std::format(
-                        "Status::getHwmonPath(): error accessing {}: {}",
-                        prefixPath.c_str(), e.what())
-                        .c_str());
+                lg2::error(
+                    "Status::getHwmonPath(): error accessing {PATH}: {ERROR}",
+                    "PATH", prefixPath, "ERROR", e.what());
                 tracedFail[instance] = true;
             }
         }
@@ -469,11 +442,9 @@
                 {
                     errorBits += " badbit";
                 }
-                log<level::ERR>(
-                    std::format(
-                        "readOccState: Failed to read OCC{} state: Read error on I/O operation -{}",
-                        instance, errorBits)
-                        .c_str());
+                lg2::error(
+                    "readOccState: Failed to read OCC{INST} state: Read error on I/O operation - {ERROR}",
+                    "INST", instance, "ERROR", errorBits);
                 lastOccReadStatus = -1;
             }
             goodFile = false;
@@ -482,11 +453,10 @@
         if (goodFile && (state != lastState))
         {
             // Trace OCC state changes
-            log<level::INFO>(
-                std::format(
-                    "Status::readOccState: OCC{} state 0x{:02X} (lastState: 0x{:02X})",
-                    instance, state, lastState)
-                    .c_str());
+            lg2::info(
+                "Status::readOccState: OCC{INST} state {STATE} (lastState: {PRIOR})",
+                "INST", instance, "STATE", lg2::hex, state, "PRIOR", lg2::hex,
+                lastState);
             lastState = state;
 #ifdef POWER10
             if (OccState(state) == OccState::ACTIVE)
@@ -505,11 +475,9 @@
                 CmdStatus status = sendAmbient();
                 if (status != CmdStatus::SUCCESS)
                 {
-                    log<level::ERR>(
-                        std::format(
-                            "readOccState: Sending Ambient failed with status {}",
-                            status)
-                            .c_str());
+                    lg2::error(
+                        "readOccState: Sending Ambient failed with status {STATUS}",
+                        "STATUS", status);
                 }
             }
 
@@ -532,11 +500,9 @@
                 // OCC is in SAFE or some other unsupported state
                 if (!safeStateDelayTimer.isEnabled())
                 {
-                    log<level::ERR>(
-                        std::format(
-                            "readOccState: Invalid OCC{} state of {}, starting safe state delay timer",
-                            instance, state)
-                            .c_str());
+                    lg2::error(
+                        "readOccState: Invalid OCC{INST} state of {STATE}, starting safe state delay timer",
+                        "INST", instance, "STATE", state);
                     // start safe delay timer (before requesting reset)
                     using namespace std::literals::chrono_literals;
                     safeStateDelayTimer.restartOnce(60s);
@@ -569,11 +535,9 @@
             // If not able to read, OCC may be offline
             if (openErrno != lastOccReadStatus)
             {
-                log<level::ERR>(
-                    std::format(
-                        "Status::readOccState: open/read failed trying to read OCC{} state (open errno={})",
-                        instance, openErrno)
-                        .c_str());
+                lg2::error(
+                    "Status::readOccState: open/read failed trying to read OCC{INST} state (open errno={ERROR})",
+                    "INST", instance, "ERROR", openErrno);
                 lastOccReadStatus = openErrno;
             }
         }
@@ -582,11 +546,10 @@
             // else this failed due to state not valid.
             if (state != lastState)
             {
-                log<level::ERR>(
-                    std::format(
-                        "Status::readOccState: OCC{} Invalid state 0x{:02X} (last state: 0x{:02X})",
-                        instance, state, lastState)
-                        .c_str());
+                lg2::error(
+                    "Status::readOccState: OCC{INST} Invalid state {STATE} (last state: {PRIOR})",
+                    "INST", instance, "STATE", lg2::hex, state, "PRIOR",
+                    lg2::hex, lastState);
             }
         }
 
@@ -601,10 +564,8 @@
         }
         else
         {
-            log<level::ERR>(
-                std::format("readOccState: failed to read OCC{} state!",
-                            instance)
-                    .c_str());
+            lg2::error("readOccState: failed to read OCC{INST} state!", "INST",
+                       instance);
 
             // State could not be determined, set it to NO State.
             lastState = 0;
@@ -624,11 +585,9 @@
     {
         if (lastOccReadStatus != 0)
         {
-            log<level::INFO>(
-                std::format(
-                    "Status::readOccState: successfully read OCC{} state: {}",
-                    instance, state)
-                    .c_str());
+            lg2::info(
+                "Status::readOccState: successfully read OCC{INST} state: {STATE}",
+                "INST", instance, "STATE", state);
             lastOccReadStatus = 0; // no error
         }
     }
@@ -667,22 +626,19 @@
     {
         if (newThrottleCause == THROTTLED_NONE)
         {
-            log<level::DEBUG>(
-                std::format(
-                    "updateThrottle: OCC{} no longer throttled (prior reason: {})",
-                    instance, throttleCause)
-                    .c_str());
+            lg2::debug(
+                "updateThrottle: OCC{INST} no longer throttled (prior reason: {REASON})",
+                "INST", instance, "REASON", throttleCause);
             throttleCause = THROTTLED_NONE;
             throttleHandle->throttled(false);
             throttleHandle->throttleCauses({});
         }
         else
         {
-            log<level::DEBUG>(
-                std::format(
-                    "updateThrottle: OCC{} is throttled with reason {} (prior reason: {})",
-                    instance, newThrottleCause, throttleCause)
-                    .c_str());
+            lg2::debug(
+                "updateThrottle: OCC{INST} is throttled with reason {REASON} (prior reason: {PRIOR})",
+                "INST", instance, "REASON", newThrottleCause, "PRIOR",
+                throttleCause);
             throttleCause = newThrottleCause;
 
             std::vector<ThrottleObj::ThrottleReasons> updatedCauses;
@@ -712,10 +668,8 @@
 void Status::readProcAssociation()
 {
     std::string managingPath = path + "/power_managing";
-    log<level::DEBUG>(
-        std::format("readProcAssociation: getting endpoints for {} ({})",
-                    managingPath, path)
-            .c_str());
+    lg2::debug("readProcAssociation: getting endpoints for {MANAGE} ({PATH})",
+               "MANAGE", managingPath, "PATH", path);
     try
     {
         utils::PropertyValue procPathProperty{};
@@ -725,27 +679,21 @@
         if (result.size() > 0)
         {
             procPath = result[0];
-            log<level::INFO>(
-                std::format("readProcAssociation: OCC{} has proc={}", instance,
-                            procPath.c_str())
-                    .c_str());
+            lg2::info("readProcAssociation: OCC{INST} has proc={PATH}", "INST",
+                      instance, "PATH", procPath);
         }
         else
         {
-            log<level::ERR>(
-                std::format(
-                    "readProcAssociation: No processor associated with OCC{} / {}",
-                    instance, path)
-                    .c_str());
+            lg2::error(
+                "readProcAssociation: No processor associated with OCC{INST} / {PATH}",
+                "INST", instance, "PATH", path);
         }
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format(
-                "readProcAssociation: Unable to get proc assocated with {} - {}",
-                path, e.what())
-                .c_str());
+        lg2::error(
+            "readProcAssociation: Unable to get proc assocated with {PATH} - {ERROR}",
+            "PATH", path, "ERROR", e.what());
         procPath = {};
     }
 }
diff --git a/pldm.cpp b/pldm.cpp
index 4e57ece..d835fbe 100644
--- a/pldm.cpp
+++ b/pldm.cpp
@@ -13,7 +13,7 @@
 #include <libpldm/transport/mctp-demux.h>
 #include <poll.h>
 
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/bus.hpp>
 #include <sdeventplus/clock.hpp>
 #include <sdeventplus/exception.hpp>
@@ -21,13 +21,10 @@
 #include <sdeventplus/source/time.hpp>
 
 #include <algorithm>
-#include <format>
 
 namespace pldm
 {
 
-using namespace phosphor::logging;
-
 using namespace sdeventplus;
 using namespace sdeventplus::source;
 constexpr auto clockId = sdeventplus::ClockId::RealTime;
@@ -59,11 +56,9 @@
     {
         if (!tracedError)
         {
-            log<level::ERR>(
-                std::format(
-                    "fetchSensorInfo: Failed to find stateSetID:{} PDR: {}",
-                    stateSetId, e.what())
-                    .c_str());
+            lg2::error(
+                "fetchSensorInfo: Failed to find stateSetID:{ID} PDR: {ERR}",
+                "ID", stateSetId, "ERR", e.what());
             tracedError = true;
         }
     }
@@ -72,11 +67,8 @@
     {
         if (!tracedError)
         {
-            log<level::ERR>(
-                std::format(
-                    "fetchSensorInfo: state sensor PDRs ({}) not present",
-                    stateSetId)
-                    .c_str());
+            lg2::error("fetchSensorInfo: state sensor PDRs ({ID}) not present",
+                       "ID", stateSetId);
             tracedError = true;
         }
         return;
@@ -85,8 +77,7 @@
     // Found PDR
     if (tracedError)
     {
-        log<level::INFO>(
-            std::format("fetchSensorInfo: found {} PDRs", pdrs.size()).c_str());
+        lg2::info("fetchSensorInfo: found {NUM} PDRs", "NUM", pdrs.size());
         tracedError = false;
     }
 
@@ -114,7 +105,7 @@
 
     if (!offsetFound)
     {
-        log<level::ERR>("pldm: state sensor PDR not found");
+        lg2::error("pldm: state sensor PDR not found");
         return;
     }
 
@@ -174,38 +165,31 @@
                 static_cast<EventState>(
                     PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_IN_SERVICE))
             {
-                log<level::INFO>(
-                    std::format("PLDM: OCC{} is RUNNING", instance).c_str());
+                lg2::info("PLDM: OCC{INST} is RUNNING", "INST", instance);
                 isRunning = true;
             }
             else if (eventState ==
                      static_cast<EventState>(
                          PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_STOPPED))
             {
-                log<level::INFO>(
-                    std::format("PLDM: OCC{} has now STOPPED", instance)
-                        .c_str());
+                lg2::info("PLDM: OCC{INST} has now STOPPED", "INST", instance);
             }
             else if (eventState ==
                      static_cast<EventState>(
                          PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_DORMANT))
             {
-                log<level::ERR>(
-                    std::format(
-                        "PLDM: OCC{} has now STOPPED and system is in SAFE MODE",
-                        instance)
-                        .c_str());
+                lg2::error(
+                    "PLDM: OCC{INST} has now STOPPED and system is in SAFE MODE",
+                    "INST", instance);
 
                 // Setting safe mode true
                 safeModeCallBack(true);
             }
             else
             {
-                log<level::WARNING>(
-                    std::format(
-                        "PLDM: Unexpected OCC Active sensor state {} for OCC{}",
-                        eventState, instance)
-                        .c_str());
+                lg2::warning(
+                    "PLDM: Unexpected OCC Active sensor state {STATE} for OCC{INST}",
+                    "STATE", eventState, "INST", instance);
                 validEvent = false;
             }
             if (validEvent)
@@ -235,20 +219,16 @@
                 outstandingHResets.erase(match);
                 if (eventState == static_cast<EventState>(SBE_HRESET_NOT_READY))
                 {
-                    log<level::ERR>(
-                        std::format("pldm: HRESET is NOT READY (OCC{})",
-                                    instance)
-                            .c_str());
+                    lg2::error("pldm: HRESET is NOT READY (OCC{INST})", "INST",
+                               instance);
                     // Stop OCC comm - OCC not usable until it becomes READY
                     occActiveCallBack(instance, false);
                     // Collect SBE FFDC
                     sbeCallBack(instance, false);
                     // Try PM Complex reset
-                    log<level::ERR>(
-                        std::format(
-                            "sensorEvent: Requesting OCC reset for OCC{}",
-                            instance)
-                            .c_str());
+                    lg2::error(
+                        "sensorEvent: Requesting OCC reset for OCC{INST}",
+                        "INST", instance);
                     resetOCC(resetInstance);
                 }
                 else if (eventState ==
@@ -265,11 +245,9 @@
                 {
                     if (eventState ==
                         static_cast<EventState>(SBE_HRESET_FAILED))
-                        log<level::ERR>(
-                            std::format(
-                                "pldm: Unexpected HRESET state {} (OCC{})",
-                                eventState, instance)
-                                .c_str());
+                        lg2::error(
+                            "pldm: Unexpected HRESET state {STATE} (OCC{INST})",
+                            "STATE", eventState, "INST", instance);
                     sbeCallBack(instance, false);
                 }
             }
@@ -299,44 +277,32 @@
 {
     if (!sensorToOCCInstance.empty())
     {
-        log<level::INFO>(
-            std::format("clearData: Clearing sensorToOCCInstance ({} entries)",
-                        sensorToOCCInstance.size())
-                .c_str());
+        lg2::info("clearData: Clearing sensorToOCCInstance ({NUM} entries)",
+                  "NUM", sensorToOCCInstance.size());
         for (auto entry : sensorToOCCInstance)
         {
-            log<level::INFO>(
-                std::format("clearData: OCC{} / sensorID: 0x{:04X}",
-                            entry.second, entry.first)
-                    .c_str());
+            lg2::info("clearData: OCC{INST} / sensorID: {ID}", "INST",
+                      entry.second, "ID", lg2::hex, entry.first);
             occActiveCallBack(entry.second, false);
         }
         sensorToOCCInstance.clear();
     }
     if (!occInstanceToEffecter.empty())
     {
-        log<level::DEBUG>(
-            std::format(
-                "clearData: Clearing occInstanceToEffecter ({} entries)",
-                occInstanceToEffecter.size())
-                .c_str());
+        lg2::debug("clearData: Clearing occInstanceToEffecter ({NUM} entries)",
+                   "NUM", occInstanceToEffecter.size());
         occInstanceToEffecter.clear();
     }
     if (!sensorToSBEInstance.empty())
     {
-        log<level::DEBUG>(
-            std::format("clearData: Clearing sensorToSBEInstance ({} entries)",
-                        sensorToSBEInstance.size())
-                .c_str());
+        lg2::debug("clearData: Clearing sensorToSBEInstance ({NUM} entries)",
+                   "NUM", sensorToSBEInstance.size());
         sensorToSBEInstance.clear();
     }
     if (!sbeInstanceToEffecter.empty())
     {
-        log<level::DEBUG>(
-            std::format(
-                "clearData: Clearing sbeInstanceToEffecter ({} entries)",
-                sbeInstanceToEffecter.size())
-                .c_str());
+        lg2::debug("clearData: Clearing sbeInstanceToEffecter ({NUM} entries)",
+                   "NUM", sbeInstanceToEffecter.size());
         sbeInstanceToEffecter.clear();
     }
 }
@@ -360,13 +326,13 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>("pldm: Failed to fetch the state effecter PDRs",
-                        entry("ERROR=%s", e.what()));
+        lg2::error("pldm: Failed to fetch the state effecter PDRs: {ERR}",
+                   "ERR", e.what());
     }
 
     if (!pdrs.size())
     {
-        log<level::ERR>("pldm: state effecter PDRs not present");
+        lg2::error("pldm: state effecter PDRs not present");
         return;
     }
 
@@ -448,8 +414,8 @@
         requestMsg);
     if (rc != PLDM_SUCCESS)
     {
-        log<level::ERR>("encode set effecter states request returned error ",
-                        entry("RC=%d", rc));
+        lg2::error("encode set effecter states request returned error rc={RC}",
+                   "RC", rc);
         request.clear();
     }
     return request;
@@ -470,11 +436,9 @@
         auto effecterEntry = occInstanceToEffecter.find(occInstanceId);
         if (effecterEntry == occInstanceToEffecter.end())
         {
-            log<level::ERR>(
-                std::format(
-                    "pldm: Failed to find a matching effecter for OCC instance {}",
-                    occInstanceId)
-                    .c_str());
+            lg2::error(
+                "pldm: Failed to find a matching effecter for OCC instance {INST}",
+                "INST", occInstanceId);
 
             return;
         }
@@ -486,8 +450,7 @@
 
         if (request.empty())
         {
-            log<level::ERR>(
-                "pldm: SetStateEffecterStates OCC reset request empty");
+            lg2::error("pldm: SetStateEffecterStates OCC reset request empty");
             return;
         }
 
@@ -498,9 +461,8 @@
     }
     else
     {
-        log<level::ERR>(
-            std::format("resetOCC: HOST is not running (OCC{})", occInstanceId)
-                .c_str());
+        lg2::error("resetOCC: HOST is not running (OCC{INST})", "INST",
+                   occInstanceId);
         clearData();
     }
 }
@@ -519,9 +481,9 @@
         auto effecterEntry = sbeInstanceToEffecter.find(sbeInstanceId);
         if (effecterEntry == sbeInstanceToEffecter.end())
         {
-            log<level::ERR>(
-                "pldm: Failed to find a matching effecter for SBE instance",
-                entry("SBE=%d", sbeInstanceId));
+            lg2::error(
+                "pldm: Failed to find a matching effecter for SBE instance {INST}",
+                "INST", sbeInstanceId);
             return;
         }
 
@@ -532,8 +494,7 @@
 
         if (request.empty())
         {
-            log<level::ERR>(
-                "pldm: SetStateEffecterStates HRESET request empty");
+            lg2::error("pldm: SetStateEffecterStates HRESET request empty");
             return;
         }
 
@@ -545,9 +506,8 @@
     }
     else
     {
-        log<level::ERR>(std::format("sendHRESET: HOST is not running (OCC{})",
-                                    sbeInstanceId)
-                            .c_str());
+        lg2::error("sendHRESET: HOST is not running (OCC{INST})", "INST",
+                   sbeInstanceId);
         clearData();
     }
 }
@@ -567,20 +527,16 @@
 
         if (rc)
         {
-            log<level::ERR>(
-                std::format(
-                    "getPldmInstanceId: Failed to alloc ID for TID {}. RC{}",
-                    tid, rc)
-                    .c_str());
+            lg2::error(
+                "getPldmInstanceId: Failed to alloc ID for TID {TID}. RC{RC}",
+                "TID", tid, "RC", rc);
             return false;
         }
         pldmInstanceID.emplace(id);
         if (!throttleTraces)
         {
-            log<level::INFO>(
-                std::format("got id {} and set PldmInstanceId to {}", id,
-                            pldmInstanceID.value())
-                    .c_str());
+            lg2::info("got id {ID} and set PldmInstanceId to {INST}", "ID", id,
+                      "INST", pldmInstanceID.value());
         }
     }
     return true;
@@ -594,18 +550,15 @@
                                        pldmInstanceID.value());
         if (rc)
         {
-            log<level::ERR>(
-                std::format(
-                    "freePldmInstanceId: Failed to free ID {} for TID {}. RC{}",
-                    pldmInstanceID.value(), tid, rc)
-                    .c_str());
+            lg2::error(
+                "freePldmInstanceId: Failed to free ID {ID} for TID {TID}. RC{RC}",
+                "ID", pldmInstanceID.value(), "TID", tid, "RC", rc);
             return;
         }
         if (!throttleTraces)
         {
-            log<level::INFO>(
-                std::format("Freed PLDM instance ID {}", pldmInstanceID.value())
-                    .c_str());
+            lg2::info("Freed PLDM instance ID {ID}", "ID",
+                      pldmInstanceID.value());
         }
         pldmInstanceID = std::nullopt;
     }
@@ -617,21 +570,17 @@
     int rc = pldm_transport_mctp_demux_init(&impl.mctpDemux);
     if (rc)
     {
-        log<level::ERR>(
-            std::format(
-                "openMctpDemuxTransport: Failed to init MCTP demux transport, errno={}/{}",
-                rc, strerror(rc))
-                .c_str());
+        lg2::error(
+            "openMctpDemuxTransport: Failed to init MCTP demux transport, errno={ERR}/{STR}",
+            "ERR", rc, "STR", strerror(rc));
         return -1;
     }
 
     if (pldm_transport_mctp_demux_map_tid(impl.mctpDemux, mctpEid, mctpEid))
     {
-        log<level::ERR>(
-            std::format(
-                "openMctpDemuxTransport: Failed to setup tid to eid mapping, errno={}/{}",
-                errno, strerror(errno))
-                .c_str());
+        lg2::error(
+            "openMctpDemuxTransport: Failed to setup tid to eid mapping, errno={ERR}/{STR}",
+            "ERR", errno, "STR", strerror(errno));
         pldmClose();
         return -1;
     }
@@ -640,20 +589,16 @@
     struct pollfd pollfd;
     if (pldm_transport_mctp_demux_init_pollfd(pldmTransport, &pollfd))
     {
-        log<level::ERR>(
-            std::format(
-                "openMctpDemuxTransport: Failed to get pollfd , errno={}/{}",
-                errno, strerror(errno))
-                .c_str());
+        lg2::error(
+            "openMctpDemuxTransport: Failed to get pollfd , errno={ERR}/{STR}",
+            "ERR", errno, "STR", strerror(errno));
         pldmClose();
         return -1;
     }
     pldmFd = pollfd.fd;
     if (!throttleTraces)
     {
-        log<level::INFO>(
-            std::format("openMctpDemuxTransport: pldmFd has fd={}", pldmFd)
-                .c_str());
+        lg2::info("openMctpDemuxTransport: pldmFd has fd={FD}", "FD", pldmFd);
     }
     return 0;
 }
@@ -664,21 +609,17 @@
     int rc = pldm_transport_af_mctp_init(&impl.afMctp);
     if (rc)
     {
-        log<level::ERR>(
-            std::format(
-                "openAfMctpTransport: Failed to init af MCTP transport, errno={}/{}",
-                rc, strerror(rc))
-                .c_str());
+        lg2::error(
+            "openAfMctpTransport: Failed to init af MCTP transport, errno={ERR}/{STR}",
+            "ERR", rc, "STR", strerror(rc));
         return -1;
     }
 
     if (pldm_transport_af_mctp_map_tid(impl.afMctp, mctpEid, mctpEid))
     {
-        log<level::ERR>(
-            std::format(
-                "openAfMctpTransport: Failed to setup tid to eid mapping, errno={}/{}",
-                errno, strerror(errno))
-                .c_str());
+        lg2::error(
+            "openAfMctpTransport: Failed to setup tid to eid mapping, errno={ERR}/{STR}",
+            "ERR", errno, "STR", strerror(errno));
         pldmClose();
         return -1;
     }
@@ -687,20 +628,16 @@
     struct pollfd pollfd;
     if (pldm_transport_af_mctp_init_pollfd(pldmTransport, &pollfd))
     {
-        log<level::ERR>(
-            std::format(
-                "openAfMctpTransport: Failed to get pollfd , errno={}/{}",
-                errno, strerror(errno))
-                .c_str());
+        lg2::error(
+            "openAfMctpTransport: Failed to get pollfd , errno={ERR}/{STR}",
+            "ERR", errno, "STR", strerror(errno));
         pldmClose();
         return -1;
     }
     pldmFd = pollfd.fd;
     if (!throttleTraces)
     {
-        log<level::INFO>(
-            std::format("openAfMctpTransport: pldmFd has fd={}", pldmFd)
-                .c_str());
+        lg2::info("openAfMctpTransport: pldmFd has fd={FD}", "FD", pldmFd);
     }
     return 0;
 }
@@ -709,10 +646,8 @@
 {
     if (pldmTransport)
     {
-        log<level::ERR>(
-            std::format("pldmOpen: pldmTransport already setup!, errno={}/{}",
-                        errno, strerror(errno))
-                .c_str());
+        lg2::error("pldmOpen: pldmTransport already setup!, errno={ERR}/{STR}",
+                   "ERR", errno, "STR", strerror(errno));
         return -1;
     }
 #if defined(PLDM_TRANSPORT_WITH_MCTP_DEMUX)
@@ -720,10 +655,8 @@
 #elif defined(PLDM_TRANSPORT_WITH_AF_MCTP)
     return openAfMctpTransport();
 #else
-    log<level::ERR>(
-        std::format("pldmOpen: Undefined pldmTransport!, errno={}/{}", errno,
-                    strerror(errno))
-            .c_str());
+    lg2::error("pldmOpen: Undefined pldmTransport!, errno={ERR}/{STR}", "ERR",
+               errno, "STR", strerror(errno));
     return -1;
 #endif
 
@@ -735,7 +668,7 @@
 {
     if (!pldmInstanceID)
     {
-        log<level::ERR>("sendPldm: No PLDM Instance ID found!");
+        lg2::error("sendPldm: No PLDM Instance ID found!");
         return;
     }
 
@@ -744,8 +677,7 @@
     {
         if (!throttleTraces)
         {
-            log<level::ERR>(
-                std::format("sendPldm: pldmOpen failed rc={}", rc).c_str());
+            lg2::error("sendPldm: pldmOpen failed rc={RC}", "RC", rc);
         }
         freePldmInstanceId();
         return;
@@ -768,11 +700,10 @@
         // Send PLDM request
         if (!throttleTraces)
         {
-            log<level::INFO>(
-                std::format(
-                    "sendPldm: calling pldm_transport_send_msg(OCC{}, instance:{}, {} bytes, timeout {})",
-                    instance, pldmInstanceID.value(), request.size(), timeout)
-                    .c_str());
+            lg2::info("sendPldm: calling pldm_transport_send_msg(OCC{INST}, "
+                      "instance:{ID}, {LEN} bytes, timeout {TO})",
+                      "INST", instance, "ID", pldmInstanceID.value(), "LEN",
+                      request.size(), "TO", timeout.count());
         }
         pldmResponseReceived = false;
         pldmResponseTimeout = false;
@@ -782,14 +713,12 @@
         auto sendErrno = errno;
         if (pldmRc != PLDM_REQUESTER_SUCCESS)
         {
-            log<level::ERR>(
-                std::format(
-                    "sendPldm: pldm_transport_send_msg failed with rc={} and errno={}/{}",
-                    static_cast<
-                        std::underlying_type_t<pldm_requester_error_codes>>(
-                        pldmRc),
-                    sendErrno, strerror(sendErrno))
-                    .c_str());
+            lg2::error(
+                "sendPldm: pldm_transport_send_msg failed with rc={RC} and errno={ERR}/{STR}",
+                "RC",
+                static_cast<std::underlying_type_t<pldm_requester_error_codes>>(
+                    pldmRc),
+                "ERR", sendErrno, "STR", strerror(sendErrno));
             pldmClose();
             return;
         }
@@ -803,25 +732,24 @@
     {
         if (!throttleTraces)
         {
-            log<level::INFO>(
-                std::format(
-                    "sendPldm: calling pldm_transport_send_msg(mctpID:{}, fd:{}, {} bytes) for OCC{}",
-                    mctpEid, pldmFd, request.size(), instance)
-                    .c_str());
+            lg2::info(
+                "sendPldm: calling pldm_transport_send_msg(mctpID:{ID}, fd:{FD}, "
+                "{LEN} bytes) for OCC{INST}",
+                "ID", mctpEid, "FD", pldmFd, "LEN", request.size(), "INST",
+                instance);
         }
         auto rc = pldm_transport_send_msg(pldmTransport, pldmTID,
                                           request.data(), request.size());
         auto sendErrno = errno;
         if (rc)
         {
-            log<level::ERR>(
-                std::format(
-                    "sendPldm: pldm_transport_send_msg(mctpID:{}, fd:{}, {} bytes) failed with rc={} and errno={}/{}",
-                    mctpEid, pldmFd, request.size(),
-                    static_cast<
-                        std::underlying_type_t<pldm_requester_error_codes>>(rc),
-                    sendErrno, strerror(sendErrno))
-                    .c_str());
+            lg2::error(
+                "sendPldm: pldm_transport_send_msg(mctpID:{ID}, fd:{FD}, {LEN} bytes) "
+                "failed with rc={RC} and errno={ERR}/{STR}",
+                "ID", mctpEid, "FD", pldmFd, "LEN", request.size(), "RC",
+                static_cast<std::underlying_type_t<pldm_requester_error_codes>>(
+                    rc),
+                "ERR", sendErrno, "STR", strerror(sendErrno));
         }
         pldmClose();
     }
@@ -844,11 +772,9 @@
     }
     if (rc < 0)
     {
-        log<level::ERR>(
-            std::format(
-                "registerPldmRspCallback: sd_event_add_io: Error({})={} : fd={} (msgType={})",
-                rc, strerror(-rc), pldmFd, msgType)
-                .c_str());
+        lg2::error(
+            "registerPldmRspCallback: sd_event_add_io: Error({ERR})={STR} : fd={FD} (msgType={MSG})",
+            "ERR", rc, "STR", strerror(-rc), "FD", pldmFd, "MSG", msgType);
     }
     else
     {
@@ -864,11 +790,10 @@
     {
         if (!throttleTraces)
         {
-            log<level::WARNING>(
-                std::format(
-                    "pldmRspExpired: timerCallback - timeout waiting for pldm response to msg:{} for OCC{}",
-                    msgType, pldmResponseOcc)
-                    .c_str());
+            lg2::warning(
+                "pldmRspExpired: timerCallback - timeout waiting for pldm "
+                "response to msg:{MSG} for OCC{INST}",
+                "MSG", msgType, "INST", pldmResponseOcc);
         }
         pldmResponseTimeout = true;
         if (pldmFd)
@@ -878,10 +803,8 @@
         if (msgType == MSG_OCC_RESET)
         {
             // reset not acked, try again
-            log<level::ERR>(
-                std::format("pldmRspExpired: retrying reset request for OCC{}",
-                            pldmResponseOcc)
-                    .c_str());
+            lg2::error("pldmRspExpired: retrying reset request for OCC{INST}",
+                       "INST", pldmResponseOcc);
             resetOCC(pldmResponseOcc);
         }
     }
@@ -915,8 +838,7 @@
 {
     if (!(revents & EPOLLIN))
     {
-        log<level::INFO>(
-            std::format("pldmRspCallback - revents={:08X}", revents).c_str());
+        lg2::info("pldmRspCallback - revents={NUM}", "NUM", lg2::hex, revents);
         return -1;
     }
 
@@ -924,8 +846,7 @@
 
     if (!pldmIface->pldmInstanceID)
     {
-        log<level::ERR>(
-            "pldmRspCallback: No outstanding PLDM Instance ID found");
+        lg2::error("pldmRspCallback: No outstanding PLDM Instance ID found");
         return -1;
     }
 
@@ -935,11 +856,9 @@
 
     if (!throttleTraces)
     {
-        log<level::INFO>(
-            std::format(
-                "pldmRspCallback: calling pldm_transport_recv_msg() instance:{}",
-                pldmIface->pldmInstanceID.value())
-                .c_str());
+        lg2::info(
+            "pldmRspCallback: calling pldm_transport_recv_msg() instance:{INST}",
+            "INST", pldmIface->pldmInstanceID.value());
     }
     auto rc = pldm_transport_recv_msg(pldmIface->pldmTransport, &pldmTID,
                                       (void**)&responseMsg, &responseMsgSize);
@@ -948,13 +867,12 @@
     {
         if (!throttleTraces)
         {
-            log<level::ERR>(
-                std::format(
-                    "pldmRspCallback: pldm_transport_recv_msg failed with rc={}, errno={}/{}",
-                    static_cast<
-                        std::underlying_type_t<pldm_requester_error_codes>>(rc),
-                    lastErrno, strerror(lastErrno))
-                    .c_str());
+            lg2::error(
+                "pldmRspCallback: pldm_transport_recv_msg failed with rc={RC}, errno={ERR}/{STR}",
+                "RC",
+                static_cast<std::underlying_type_t<pldm_requester_error_codes>>(
+                    rc),
+                "ERR", lastErrno, "STR", strerror(lastErrno));
         }
         return -1;
     }
@@ -962,11 +880,9 @@
     // We got the response for the PLDM request msg that was sent
     if (!throttleTraces)
     {
-        log<level::INFO>(
-            std::format(
-                "pldmRspCallback: pldm_transport_recv_msg() rsp was {} bytes",
-                responseMsgSize)
-                .c_str());
+        lg2::info(
+            "pldmRspCallback: pldm_transport_recv_msg() rsp was {LEN} bytes",
+            "LEN", responseMsgSize);
     }
 
     if (pldmIface->pldmRspTimer.isEnabled())
@@ -985,10 +901,8 @@
     auto response = reinterpret_cast<pldm_msg*>(responseMsgPtr.get());
     if (response->payload[0] != PLDM_SUCCESS)
     {
-        log<level::ERR>(
-            std::format("pldmRspCallback: payload[0] was not success: {}",
-                        response->payload[0])
-                .c_str());
+        lg2::error("pldmRspCallback: payload[0] was not success: {STATUS}",
+                   "STATUS", response->payload[0]);
         pldmIface->pldmClose();
         return -1;
     }
@@ -1001,11 +915,9 @@
         response, responseMsgSize, &compCode, &sensorCount, field);
     if ((msgRc != PLDM_SUCCESS) || (compCode != PLDM_SUCCESS))
     {
-        log<level::ERR>(
-            std::format(
-                "pldmRspCallback: decode_get_state_sensor_readings failed with rc={} and compCode={}",
-                msgRc, compCode)
-                .c_str());
+        lg2::error(
+            "pldmRspCallback: decode_get_state_sensor_readings failed with rc={RC} and compCode={CC}",
+            "RC", msgRc, "CC", compCode);
         pldmIface->pldmClose();
         return -1;
     }
@@ -1018,18 +930,15 @@
 
     if (occSensorState == PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_IN_SERVICE)
     {
-        log<level::INFO>(
-            std::format("pldmRspCallback: OCC{} is RUNNING", instance).c_str());
+        lg2::info("pldmRspCallback: OCC{INST} is RUNNING", "INST", instance);
         pldmIface->occActiveCallBack(instance, true);
     }
     else if (occSensorState ==
              PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_DORMANT)
     {
-        log<level::ERR>(
-            std::format(
-                "pldmRspCallback: OCC{} has now STOPPED and system is in SAFE MODE",
-                instance)
-                .c_str());
+        lg2::error(
+            "pldmRspCallback: OCC{INST} has now STOPPED and system is in SAFE MODE",
+            "INST", instance);
 
         // Setting safe mode true
         pldmIface->safeModeCallBack(true);
@@ -1039,9 +948,8 @@
     else if (occSensorState ==
              PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_STOPPED)
     {
-        log<level::INFO>(
-            std::format("pldmRspCallback: OCC{} is not running", instance)
-                .c_str());
+        lg2::info("pldmRspCallback: OCC{INST} is not running", "INST",
+                  instance);
         pldmIface->occActiveCallBack(instance, false);
     }
     else
@@ -1052,11 +960,10 @@
                rspLength);
         if (!throttleTraces)
         {
-            log<level::WARNING>(
-                std::format(
-                    "pldmRspCallback: Unexpected State: {} - PLDM response ({} bytes) for OCC{}:",
-                    occSensorState, rspLength, instance)
-                    .c_str());
+            lg2::warning(
+                "pldmRspCallback: Unexpected State: {STATE} - PLDM response "
+                "({LEN} bytes) for OCC{INST}:",
+                "STATE", occSensorState, "LEN", rspLength, "INST", instance);
             dump_hex(pldmResponse);
         }
     }
@@ -1070,8 +977,8 @@
 {
     if (!(revents & EPOLLIN))
     {
-        log<level::INFO>(
-            std::format("pldmResetCallback - revents={:08X}", revents).c_str());
+        lg2::info("pldmResetCallback - revents={NUM}", "NUM", lg2::hex,
+                  revents);
         return -1;
     }
 
@@ -1079,8 +986,7 @@
 
     if (!pldmIface->pldmInstanceID)
     {
-        log<level::ERR>(
-            "pldmResetCallback: No outstanding PLDM Instance ID found");
+        lg2::error("pldmResetCallback: No outstanding PLDM Instance ID found");
         return -1;
     }
 
@@ -1090,11 +996,9 @@
 
     if (!throttleTraces)
     {
-        log<level::INFO>(
-            std::format(
-                "pldmResetCallback: calling pldm_transport_recv_msg() instance:{}",
-                pldmIface->pldmInstanceID.value())
-                .c_str());
+        lg2::info(
+            "pldmResetCallback: calling pldm_transport_recv_msg() instance:{ID}",
+            "ID", pldmIface->pldmInstanceID.value());
     }
     auto rc = pldm_transport_recv_msg(pldmIface->pldmTransport, &pldmTID,
                                       (void**)&responseMsg, &responseMsgSize);
@@ -1103,13 +1007,12 @@
     {
         if (!throttleTraces)
         {
-            log<level::ERR>(
-                std::format(
-                    "pldmResetCallback: pldm_transport_recv_msg failed with rc={}, errno={}/{}",
-                    static_cast<
-                        std::underlying_type_t<pldm_requester_error_codes>>(rc),
-                    lastErrno, strerror(lastErrno))
-                    .c_str());
+            lg2::error(
+                "pldmResetCallback: pldm_transport_recv_msg failed with rc={RC}, errno={ERR}/{STR}",
+                "RC",
+                static_cast<std::underlying_type_t<pldm_requester_error_codes>>(
+                    rc),
+                "ERR", lastErrno, "STR", strerror(lastErrno));
         }
         return -1;
     }
@@ -1117,11 +1020,9 @@
     // We got the response for the PLDM request msg that was sent
     if (!throttleTraces)
     {
-        log<level::INFO>(
-            std::format(
-                "pldmResetCallback: pldm_transport_recv_msg() rsp was {} bytes",
-                responseMsgSize)
-                .c_str());
+        lg2::info(
+            "pldmResetCallback: pldm_transport_recv_msg() rsp was {LEN} bytes",
+            "LEN", responseMsgSize);
     }
 
     if (pldmIface->pldmRspTimer.isEnabled())
@@ -1140,29 +1041,24 @@
     auto response = reinterpret_cast<pldm_msg*>(responseMsgPtr.get());
     if (response->payload[0] != PLDM_SUCCESS)
     {
-        log<level::ERR>(
-            std::format(
-                "pldmResetCallback: Reset FAILED ({}) - payload[0] was not success: {}",
-                msgType, response->payload[0])
-                .c_str());
+        lg2::error(
+            "pldmResetCallback: Reset FAILED ({MSG}) - payload[0] was not success: {STATUS}",
+            "MSG", msgType, "STATUS", response->payload[0]);
         pldmIface->pldmClose();
 
         if (msgType == MSG_OCC_RESET)
         {
             // Retry reset request
-            log<level::ERR>(
-                std::format(
-                    "pldmResetCallback: retrying reset request for OCC{}",
-                    resetInstance)
-                    .c_str());
+            lg2::error(
+                "pldmResetCallback: retrying reset request for OCC{INST}",
+                "INST", resetInstance);
             pldmIface->resetOCC(resetInstance);
         }
         return -1;
     }
     else
     {
-        log<level::INFO>(
-            "pldmResetCallback: Reset has been successfully started");
+        lg2::info("pldmResetCallback: Reset has been successfully started");
     }
 
     pldmIface->pldmClose();
@@ -1177,8 +1073,7 @@
 {
     if (!getPldmInstanceId())
     {
-        log<level::ERR>(
-            "encodeGetStateSensorRequest: failed to getPldmInstanceId");
+        lg2::error("encodeGetStateSensorRequest: failed to getPldmInstanceId");
         return std::vector<uint8_t>();
     }
 
@@ -1192,11 +1087,9 @@
                                                       sensorId, sRearm, 0, msg);
     if (msgRc != PLDM_SUCCESS)
     {
-        log<level::ERR>(
-            std::format(
-                "encodeGetStateSensorRequest: Failed to encode sensorId:0x{:08X} for OCC{} (rc={})",
-                sensorId, instance, msgRc)
-                .c_str());
+        lg2::error(
+            "encodeGetStateSensorRequest: Failed to encode sensorId:{ID} for OCC{INST} (rc={RC})",
+            "ID", lg2::hex, sensorId, "INST", instance, "RC", msgRc);
     }
     return request;
 }
@@ -1209,11 +1102,9 @@
     {
         if (!throttleTraces && !tracedOnce)
         {
-            log<level::WARNING>(
-                std::format(
-                    "checkActiveSensor: already waiting on OCC{} (fd={})",
-                    pldmResponseOcc, pldmFd)
-                    .c_str());
+            lg2::warning(
+                "checkActiveSensor: already waiting on OCC{INST} (fd={FD})",
+                "INST", pldmResponseOcc, "FD", pldmFd);
             tracedOnce = true;
         }
         return;
@@ -1235,10 +1126,8 @@
         // Query the OCC Active Sensor state for this instance
         if (!throttleTraces)
         {
-            log<level::INFO>(
-                std::format("checkActiveSensor: OCC{} / sensorID: 0x{:04X}",
-                            instance, entry->first)
-                    .c_str());
+            lg2::info("checkActiveSensor: OCC{INST} / sensorID: {ID}", "INST",
+                      instance, "ID", lg2::hex, entry->first);
         }
 
         // Encode GetStateSensorReadings PLDM message
@@ -1256,12 +1145,10 @@
     {
         if (!throttleTraces)
         {
-            log<level::ERR>(
-                std::format(
-                    "checkActiveSensor: Unable to find PLDM sensor for OCC{}",
-                    instance)
-                    .c_str());
-            log<level::INFO>(
+            lg2::error(
+                "checkActiveSensor: Unable to find PLDM sensor for OCC{INST}",
+                "INST", instance);
+            lg2::info(
                 "checkActiveSensor: fetching STATE_SET_OPERATIONAL_RUNNING_STATUS");
         }
         fetchSensorInfo(PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS,
@@ -1275,11 +1162,11 @@
     {
         if (throttle)
         {
-            log<level::WARNING>("PLDM traces being throttled");
+            lg2::warning("PLDM traces being throttled");
         }
         else
         {
-            log<level::INFO>("PLDM traces no longer being throttled");
+            lg2::info("PLDM traces no longer being throttled");
         }
         throttleTraces = throttle;
     }
diff --git a/powercap.cpp b/powercap.cpp
index a70d4e9..7ccc6d9 100644
--- a/powercap.cpp
+++ b/powercap.cpp
@@ -1,11 +1,10 @@
 #include "occ_status.hpp"
 
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <powercap.hpp>
 
 #include <cassert>
 #include <filesystem>
-#include <format>
 
 namespace open_power
 {
@@ -23,7 +22,6 @@
 constexpr auto POWER_CAP_HARD_MIN = "MinPowerCapValue";
 constexpr auto POWER_CAP_MAX = "MaxPowerCapValue";
 
-using namespace phosphor::logging;
 namespace fs = std::filesystem;
 
 void PowerCap::updatePcapBounds()
@@ -50,11 +48,9 @@
     }
     else
     {
-        log<level::ERR>(
-            std::format(
-                "updatePcapBounds: unable to find pcap_min_soft file: {} (errno={})",
-                pcapBasePathname.c_str(), errno)
-                .c_str());
+        lg2::error(
+            "updatePcapBounds: unable to find pcap_min_soft file: {FILE} (errno={ERR})",
+            "FILE", pcapBasePathname, "ERR", errno);
     }
 
     std::ifstream minFile(minName, std::ios::in);
@@ -67,11 +63,9 @@
     }
     else
     {
-        log<level::ERR>(
-            std::format(
-                "updatePcapBounds: unable to find cap_min file: {} (errno={})",
-                pcapBasePathname.c_str(), errno)
-                .c_str());
+        lg2::error(
+            "updatePcapBounds: unable to find cap_min file: {FILE} (errno={ERR})",
+            "FILE", pcapBasePathname, "ERR", errno);
     }
 
     std::ifstream maxFile(maxName, std::ios::in);
@@ -84,11 +78,9 @@
     }
     else
     {
-        log<level::ERR>(
-            std::format(
-                "updatePcapBounds: unable to find cap_max file: {} (errno={})",
-                pcapBasePathname.c_str(), errno)
-                .c_str());
+        lg2::error(
+            "updatePcapBounds: unable to find cap_max file: {FILE} (errno={ERR})",
+            "FILE", pcapBasePathname, "ERR", errno);
     }
 
     // Save the power cap bounds to dbus
@@ -106,11 +98,9 @@
             if ((hwmonUserCap != 0) && (dbusUserCap != hwmonUserCap))
             {
                 // User power cap is enabled, but does not match dbus
-                log<level::ERR>(
-                    std::format(
-                        "updatePcapBounds: user powercap mismatch (hwmon:{}W, bdus:{}W) - using dbus",
-                        hwmonUserCap, dbusUserCap)
-                        .c_str());
+                lg2::error(
+                    "updatePcapBounds: user powercap mismatch (hwmon:{HCAP}W, bdus:{DCAP}W) - using dbus",
+                    "HCAP", hwmonUserCap, "DCAP", dbusUserCap);
                 auto occInput = getOccInput(dbusUserCap, pcapEnabled);
                 writeOcc(occInput);
             }
@@ -123,19 +113,16 @@
             {
                 newCap = capSoftMin;
             }
-            log<level::ERR>(
-                std::format(
-                    "updatePcapBounds: user powercap {}W is outside bounds "
-                    "(soft min:{}, min:{}, max:{})",
-                    dbusUserCap, capSoftMin, capHardMin, capMax)
-                    .c_str());
+            lg2::error(
+                "updatePcapBounds: user powercap {CAP}W is outside bounds "
+                "(soft min:{SMIN}, min:{MIN}, max:{MAX})",
+                "CAP", dbusUserCap, "SMIN", capSoftMin, "MIN", capHardMin,
+                "MAX", capMax);
             try
             {
-                log<level::INFO>(
-                    std::format(
-                        "updatePcapBounds: Updating user powercap from {} to {}W",
-                        hwmonUserCap, newCap)
-                        .c_str());
+                lg2::info(
+                    "updatePcapBounds: Updating user powercap from {OLD} to {NEW}W",
+                    "OLD", hwmonUserCap, "NEW", newCap);
                 utils::setProperty(PCAP_PATH, PCAP_INTERFACE, POWER_CAP_PROP,
                                    newCap);
                 auto occInput = getOccInput(newCap, pcapEnabled);
@@ -143,11 +130,9 @@
             }
             catch (const sdbusplus::exception_t& e)
             {
-                log<level::ERR>(
-                    std::format(
-                        "updatePcapBounds: Failed to update user powercap due to ",
-                        e.what())
-                        .c_str());
+                lg2::error(
+                    "updatePcapBounds: Failed to update user powercap due to {ERR}",
+                    "ERR", e.what());
             }
         }
     }
@@ -178,9 +163,8 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>("Failed to get PowerCap property",
-                        entry("ERROR=%s", e.what()),
-                        entry("PATH=%s", PCAP_PATH));
+        lg2::error("Failed to get PowerCap property: path={PATH}: {ERR}",
+                   "PATH", PCAP_PATH, "ERR", e.what());
 
         return 0;
     }
@@ -198,9 +182,8 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>("Failed to get PowerCapEnable property",
-                        entry("ERROR=%s", e.what()),
-                        entry("PATH=%s", PCAP_PATH));
+        lg2::error("Failed to get PowerCapEnable property: path={PATH}: {ERR}",
+                   "PATH", PCAP_PATH, "ERR", e.what());
 
         return false;
     }
@@ -227,9 +210,8 @@
     }
     else
     {
-        log<level::ERR>(std::format("Power Cap base filename not found: {}",
-                                    pcapBasePathname.c_str())
-                            .c_str());
+        lg2::error("Power Cap base filename not found: {FILE}", "FILE",
+                   pcapBasePathname);
     }
 
     // return empty path
@@ -250,10 +232,8 @@
     fs::path fileName = getPcapFilename(std::regex{"power\\d+_cap_user$"});
     if (fileName.empty())
     {
-        log<level::ERR>(
-            std::format("Could not find a power cap file to write to: {})",
-                        pcapBasePathname.c_str())
-                .c_str());
+        lg2::error("Could not find a power cap file to write to: {FILE})",
+                   "FILE", pcapBasePathname);
         return;
     }
 
@@ -265,17 +245,15 @@
     std::ofstream file(fileName, std::ios::out);
     if (file)
     {
-        log<level::INFO>(std::format("Writing {}uW to {}", pcapString.c_str(),
-                                     fileName.c_str())
-                             .c_str());
+        lg2::info("Writing {CAP}uW to {FILE}", "CAP", pcapString, "FILE",
+                  fileName);
         file << pcapString;
         file.close();
     }
     else
     {
-        log<level::ERR>(std::format("Failed writing {}uW to {} (errno={})",
-                                    microWatts, fileName.c_str(), errno)
-                            .c_str());
+        lg2::error("Failed writing {CAP}uW to {FILE} (errno={ERR})", "CAP",
+                   microWatts, "FILE", fileName, "ERR", errno);
     }
 
     return;
@@ -290,11 +268,9 @@
     fs::path userCapName = getPcapFilename(std::regex{"power\\d+_cap_user$"});
     if (userCapName.empty())
     {
-        log<level::ERR>(
-            std::format(
-                "readUserCapHwmon: Could not find a power cap file to read: {})",
-                pcapBasePathname.c_str())
-                .c_str());
+        lg2::error(
+            "readUserCapHwmon: Could not find a power cap file to read: {FILE})",
+            "FILE", pcapBasePathname);
         return 0;
     }
 
@@ -310,10 +286,8 @@
     }
     else
     {
-        log<level::ERR>(
-            std::format("readUserCapHwmon: Failed reading {} (errno={})",
-                        userCapName.c_str(), errno)
-                .c_str());
+        lg2::error("readUserCapHwmon: Failed reading {FILE} (errno={ERR})",
+                   "FILE", userCapName, "ERR", errno);
     }
 
     return userCap;
@@ -352,11 +326,9 @@
         else
         {
             // Ignore other properties
-            log<level::DEBUG>(
-                std::format(
-                    "pcapChanged: Unknown power cap property changed {} to {}",
-                    prop.c_str(), std::get<uint32_t>(value))
-                    .c_str());
+            lg2::debug(
+                "pcapChanged: Unknown power cap property changed {PROP} to {VAL}",
+                "PROP", prop, "VAL", std::get<uint32_t>(value));
         }
     }
 
@@ -365,32 +337,26 @@
     readDbusPcapLimits(capSoftMin, capHardMin, capMax);
     if (((pcap > 0) && (pcap < capSoftMin)) || ((pcap == 0) && (pcapEnabled)))
     {
-        log<level::ERR>(
-            std::format(
-                "pcapChanged: Power cap of {}W is lower than allowed (soft min:{}, min:{}) - using soft min",
-                pcap, capSoftMin, capHardMin)
-                .c_str());
+        lg2::error(
+            "pcapChanged: Power cap of {CAP}W is lower than allowed (soft min:{SMIN}, min:{MIN}) - using soft min",
+            "CAP", pcap, "SMIN", capSoftMin, "MIN", capHardMin);
         pcap = capSoftMin;
         utils::setProperty(PCAP_PATH, PCAP_INTERFACE, POWER_CAP_PROP, pcap);
     }
     else if (pcap > capMax)
     {
-        log<level::ERR>(
-            std::format(
-                "pcapChanged: Power cap of {}W is higher than allowed (max:{}) - using max",
-                pcap, capSoftMin, capHardMin)
-                .c_str());
+        lg2::error(
+            "pcapChanged: Power cap of {CAP}W is higher than allowed (max:{MAX}) - using max",
+            "CAP", pcap, "MAX", capMax);
         pcap = capMax;
         utils::setProperty(PCAP_PATH, PCAP_INTERFACE, POWER_CAP_PROP, pcap);
     }
 
     if (changeFound)
     {
-        log<level::INFO>(
-            std::format(
-                "Power Cap Property Change (cap={}W (input), enabled={})", pcap,
-                pcapEnabled ? 'y' : 'n')
-                .c_str());
+        lg2::info(
+            "Power Cap Property Change (cap={CAP}W (input), enabled={ENABLE})",
+            "CAP", pcap, "ENABLE", pcapEnabled);
 
         // Determine desired action to write to occ
         auto occInput = getOccInput(pcap, pcapEnabled);
@@ -414,11 +380,9 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format(
-                "updateDbusPcapLimits: Failed to set SOFT PCAP to {}W due to {}",
-                softMin, e.what())
-                .c_str());
+        lg2::error(
+            "updateDbusPcapLimits: Failed to set SOFT PCAP to {MIN}W due to {ERR}",
+            "MIN", softMin, "ERR", e.what());
         complete = false;
     }
 
@@ -429,11 +393,9 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format(
-                "updateDbusPcapLimits: Failed to set HARD PCAP to {}W due to {}",
-                hardMin, e.what())
-                .c_str());
+        lg2::error(
+            "updateDbusPcapLimits: Failed to set HARD PCAP to {MIN}W due to {ERR}",
+            "MIN", hardMin, "ERR", e.what());
         complete = false;
     }
 
@@ -443,11 +405,9 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format(
-                "updateDbusPcapLimits: Failed to set MAX PCAP to {}W due to {}",
-                max, e.what())
-                .c_str());
+        lg2::error(
+            "updateDbusPcapLimits: Failed to set MAX PCAP to {MAX}W due to {ERR}",
+            "MAX", max, "ERR", e.what());
         complete = false;
     }
 
@@ -469,10 +429,8 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format("readDbusPcapLimits: Failed to get SOFT PCAP due to {}",
-                        e.what())
-                .c_str());
+        lg2::error("readDbusPcapLimits: Failed to get SOFT PCAP due to {ERR}",
+                   "ERR", e.what());
         softMin = 0;
         complete = false;
     }
@@ -485,10 +443,8 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format("readDbusPcapLimits: Failed to get HARD PCAP due to {}",
-                        e.what())
-                .c_str());
+        lg2::error("readDbusPcapLimits: Failed to get HARD PCAP due to {ERR}",
+                   "ERR", e.what());
         hardMin = 0;
         complete = false;
     }
@@ -500,10 +456,8 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format("readDbusPcapLimits: Failed to get MAX PCAP due to {}",
-                        e.what())
-                .c_str());
+        lg2::error("readDbusPcapLimits: Failed to get MAX PCAP due to {ERR}",
+                   "ERR", e.what());
         max = INT_MAX;
         complete = false;
     }
diff --git a/powermode.cpp b/powermode.cpp
index 2179bd8..51e95f5 100644
--- a/powermode.cpp
+++ b/powermode.cpp
@@ -3,14 +3,12 @@
 #include <fcntl.h>
 #include <sys/ioctl.h>
 
-#include <format>
-
 #ifdef POWERVM_CHECK
 #include <com/ibm/Host/Target/server.hpp>
 #endif
 #include <org/open_power/OCC/Device/error.hpp>
 #include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/Control/Power/Mode/server.hpp>
 
@@ -92,11 +90,9 @@
         }
         else
         {
-            log<level::ERR>(
-                std::format(
-                    "PowerMode: Persisted power mode ({}/{}) is not valid. Reading system default mode",
-                    currentMode, oemModeData)
-                    .c_str());
+            lg2::error("PowerMode: Persisted power mode ({MODE}/{DATA}) is not "
+                       "valid. Reading system default mode",
+                       "MODE", currentMode, "DATA", oemModeData);
             persistedData.invalidateMode();
             // Read default power mode
             initPersistentData();
@@ -108,7 +104,7 @@
 {
     if (!ipsObject)
     {
-        log<level::INFO>("createIpsObject: Creating IPS object");
+        lg2::info("createIpsObject: Creating IPS object");
         ipsObject =
             std::make_unique<IpsInterface>(utils::getBus(), ipsObjectPath);
 
@@ -136,7 +132,7 @@
         // Stop watching for IPS state changes.
         removeIpsWatch();
 
-        log<level::INFO>("removeIpsObject: Deleting IPS object");
+        lg2::info("removeIpsObject: Deleting IPS object");
         ipsObject.reset(nullptr);
     }
     needToSendIpsData = false;
@@ -149,11 +145,9 @@
     {
         if (masterOccPath != path)
         {
-            log<level::ERR>(
-                std::format(
-                    "PowerMode::setMasterOcc: Master changed (was OCC{}, {})",
-                    occInstance, masterOccPath)
-                    .c_str());
+            lg2::error(
+                "PowerMode::setMasterOcc: Master changed (was OCC{INST}, {PATH})",
+                "INST", occInstance, "PATH", masterOccPath);
             if (occCmd)
             {
                 occCmd.reset();
@@ -162,9 +156,8 @@
     }
     path = masterOccPath;
     occInstance = path.back() - '0';
-    log<level::DEBUG>(std::format("PowerMode::setMasterOcc(OCC{}, {})",
-                                  occInstance, path.c_str())
-                          .c_str());
+    lg2::debug("PowerMode::setMasterOcc(OCC{INST}, {PATH})", "INST",
+               occInstance, "PATH", path);
     if (!occCmd)
     {
         occCmd = std::make_unique<open_power::occ::OccCommand>(
@@ -176,7 +169,7 @@
 // Set the state of power mode lock. Writing persistent data via dbus method.
 bool PowerMode::powerModeLock()
 {
-    log<level::INFO>("PowerMode::powerModeLock: locking mode change");
+    lg2::info("PowerMode::powerModeLock: locking mode change");
     persistedData.updateModeLock(true); // write persistent data
     return true;
 }
@@ -185,9 +178,8 @@
 bool PowerMode::powerModeLockStatus()
 {
     bool status = persistedData.getModeLock(); // read persistent data
-    log<level::INFO>(std::format("PowerMode::powerModeLockStatus: {}",
-                                 status ? "locked" : "unlocked")
-                         .c_str());
+    lg2::info("PowerMode::powerModeLockStatus: {STATUS}", "STATUS",
+              status ? "locked" : "unlocked");
     return status;
 }
 
@@ -196,7 +188,7 @@
 {
     if (persistedData.getModeLock())
     {
-        log<level::INFO>("PowerMode::setMode: mode change blocked");
+        lg2::info("PowerMode::setMode: mode change blocked");
         return false;
     }
 
@@ -248,7 +240,7 @@
         return SysPwrMode::BALANCED_PERF;
     }
 
-    log<level::WARNING>("getInternalMode: Invalid PowerMode specified");
+    lg2::warning("getInternalMode: Invalid PowerMode specified");
     return SysPwrMode::NO_CHANGE;
 }
 
@@ -291,10 +283,9 @@
         }
         else
         {
-            log<level::ERR>(
-                std::format("convertStringToMode: Invalid Power Mode: {} ({})",
-                            shortMode, e.what())
-                    .c_str());
+            lg2::error(
+                "convertStringToMode: Invalid Power Mode: {MODE} ({DATA})",
+                "MODE", shortMode, "DATA", e.what());
         }
     }
     return newMode;
@@ -327,8 +318,7 @@
         powerVmTarget = true;
     }
 
-    log<level::DEBUG>(
-        std::format("isPowerVM returning {}", powerVmTarget).c_str());
+    lg2::debug("isPowerVM returning {VAL}", "VAL", powerVmTarget);
 #endif
 
     return powerVmTarget;
@@ -346,10 +336,8 @@
             // Unable to read defaults
             return false;
         }
-        log<level::INFO>(
-            std::format("PowerMode::initPersistentData: Using default mode: {}",
-                        currentMode)
-                .c_str());
+        lg2::info("PowerMode::initPersistentData: Using default mode: {MODE}",
+                  "MODE", currentMode);
 
         // Save default mode as current mode
         persistedData.updateMode(currentMode, 0);
@@ -392,11 +380,9 @@
 {
     if (!isValidMode(newMode))
     {
-        log<level::ERR>(
-            std::format(
-                "PowerMode::updateDbusMode - Requested power mode not supported: {}",
-                newMode)
-                .c_str());
+        lg2::error(
+            "PowerMode::updateDbusMode - Requested power mode not supported: {MODE}",
+            "MODE", newMode);
         return false;
     }
 
@@ -473,15 +459,14 @@
         if (!masterActive || !masterOccSet)
         {
             // Nothing to do until OCC goes active
-            log<level::DEBUG>(
-                "PowerMode::sendModeChange: OCC master not active");
+            lg2::debug("PowerMode::sendModeChange: OCC master not active");
             return CmdStatus::SUCCESS;
         }
 
         if (!isPowerVM())
         {
             // Mode change is only supported on PowerVM systems
-            log<level::DEBUG>(
+            lg2::debug(
                 "PowerMode::sendModeChange: MODE CHANGE does not get sent on non-PowerVM systems");
             return CmdStatus::SUCCESS;
         }
@@ -497,11 +482,10 @@
         cmd.push_back(oemModeData >> 8);   // Mode Data (Freq Point)
         cmd.push_back(oemModeData & 0xFF); //
         cmd.push_back(0x00);               // reserved
-        log<level::INFO>(
-            std::format(
-                "PowerMode::sendModeChange: SET_MODE({},{}) command to OCC{} ({} bytes)",
-                newMode, oemModeData, occInstance, cmd.size())
-                .c_str());
+        lg2::info(
+            "PowerMode::sendModeChange: SET_MODE({MODE},{DATA}) command to OCC{INST} ({LEN} bytes)",
+            "MODE", uint8_t(newMode), "DATA", oemModeData, "INST", occInstance,
+            "LEN", cmd.size());
         status = occCmd->send(cmd, rsp);
         if (status == CmdStatus::SUCCESS)
         {
@@ -518,18 +502,16 @@
                 }
                 else
                 {
-                    log<level::ERR>(
-                        std::format(
-                            "PowerMode::sendModeChange: SET MODE failed with status 0x{:02X}",
-                            rsp[2])
-                            .c_str());
+                    lg2::error(
+                        "PowerMode::sendModeChange: SET MODE failed with status {STATUS}",
+                        "STATUS", lg2::hex, rsp[2]);
                     dump_hex(rsp);
                     status = CmdStatus::FAILURE;
                 }
             }
             else
             {
-                log<level::ERR>(
+                lg2::error(
                     "PowerMode::sendModeChange: INVALID SET MODE response");
                 dump_hex(rsp);
                 status = CmdStatus::FAILURE;
@@ -537,20 +519,16 @@
         }
         else
         {
-            log<level::ERR>(
-                std::format(
-                    "PowerMode::sendModeChange: SET_MODE FAILED with status={}",
-                    status)
-                    .c_str());
+            lg2::error(
+                "PowerMode::sendModeChange: SET_MODE FAILED with status={STATUS}",
+                "STATUS", lg2::hex, uint8_t(status));
         }
     }
     else
     {
-        log<level::ERR>(
-            std::format(
-                "PowerMode::sendModeChange: Unable to set power mode to {}",
-                newMode)
-                .c_str());
+        lg2::error(
+            "PowerMode::sendModeChange: Unable to set power mode to {MODE}",
+            "MODE", newMode);
         status = CmdStatus::FAILURE;
     }
 
@@ -574,7 +552,7 @@
 
     if (!ipsObject)
     {
-        log<level::WARNING>(
+        lg2::warning(
             "ipsChanged: Idle Power Saver can not be modified in an ECO power mode");
         return;
     }
@@ -584,18 +562,16 @@
     if (ipsEntry != ipsProperties.end())
     {
         ipsEnabled = std::get<bool>(ipsEntry->second);
-        log<level::INFO>(
-            std::format("Idle Power Saver change: Enabled={}", ipsEnabled)
-                .c_str());
+        lg2::info("Idle Power Saver change: Enabled={STAT}", "STAT",
+                  ipsEnabled);
         parmsChanged = true;
     }
     ipsEntry = ipsProperties.find(IPS_ENTER_UTIL);
     if (ipsEntry != ipsProperties.end())
     {
         enterUtil = std::get<uint8_t>(ipsEntry->second);
-        log<level::INFO>(
-            std::format("Idle Power Saver change: Enter Util={}%", enterUtil)
-                .c_str());
+        lg2::info("Idle Power Saver change: Enter Util={UTIL}%", "UTIL",
+                  enterUtil);
         parmsChanged = true;
     }
     ipsEntry = ipsProperties.find(IPS_ENTER_TIME);
@@ -604,18 +580,16 @@
         std::chrono::milliseconds ms(std::get<uint64_t>(ipsEntry->second));
         enterTime =
             std::chrono::duration_cast<std::chrono::seconds>(ms).count();
-        log<level::INFO>(
-            std::format("Idle Power Saver change: Enter Time={}sec", enterTime)
-                .c_str());
+        lg2::info("Idle Power Saver change: Enter Time={TIME}sec", "TIME",
+                  enterTime);
         parmsChanged = true;
     }
     ipsEntry = ipsProperties.find(IPS_EXIT_UTIL);
     if (ipsEntry != ipsProperties.end())
     {
         exitUtil = std::get<uint8_t>(ipsEntry->second);
-        log<level::INFO>(
-            std::format("Idle Power Saver change: Exit Util={}%", exitUtil)
-                .c_str());
+        lg2::info("Idle Power Saver change: Exit Util={UTIL}%", "UTIL",
+                  exitUtil);
         parmsChanged = true;
     }
     ipsEntry = ipsProperties.find(IPS_EXIT_TIME);
@@ -623,9 +597,8 @@
     {
         std::chrono::milliseconds ms(std::get<uint64_t>(ipsEntry->second));
         exitTime = std::chrono::duration_cast<std::chrono::seconds>(ms).count();
-        log<level::INFO>(
-            std::format("Idle Power Saver change: Exit Time={}sec", exitTime)
-                .c_str());
+        lg2::info("Idle Power Saver change: Exit Time={TIME}sec", "TIME",
+                  exitTime);
         parmsChanged = true;
     }
 
@@ -635,7 +608,7 @@
         {
             // Setting the exitUtil to 0 will force restoring the default IPS
             // parmeters (0 is not valid exit utilization)
-            log<level::INFO>(
+            lg2::info(
                 "Idle Power Saver Exit Utilization is 0%. Restoring default parameters");
             // Read the default IPS parameters, write persistent file and update
             // DBus
@@ -685,11 +658,9 @@
 
     if (enterUtil > exitUtil)
     {
-        log<level::ERR>(
-            std::format(
-                "ERROR: Idle Power Saver Enter Utilization ({}%) is > Exit Utilization ({}%) - using Exit for both",
-                enterUtil, exitUtil)
-                .c_str());
+        lg2::error(
+            "ERROR: Idle Power Saver Enter Utilization ({ENTER}%) is > Exit Utilization ({EXIT}%) - using Exit for both",
+            "ENTER", enterUtil, "EXIT", exitUtil);
         enterUtil = exitUtil;
     }
 
@@ -715,7 +686,7 @@
     }
     else
     {
-        log<level::WARNING>("updateDbusIPS: No IPS object was found");
+        lg2::warning("updateDbusIPS: No IPS object was found");
     }
 
     return true;
@@ -733,7 +704,7 @@
     if (!isPowerVM())
     {
         // Idle Power Saver data is only supported on PowerVM systems
-        log<level::DEBUG>(
+        lg2::debug(
             "PowerMode::sendIpsData: SET_CFG_DATA[IPS] does not get sent on non-PowerVM systems");
         return CmdStatus::SUCCESS;
     }
@@ -741,7 +712,7 @@
     if (!ipsObject)
     {
         // Idle Power Saver data is not available in Eco Modes
-        log<level::INFO>(
+        lg2::info(
             "PowerMode::sendIpsData: Skipping IPS data due to being in an ECO Power Mode");
         return CmdStatus::SUCCESS;
     }
@@ -751,11 +722,10 @@
     uint16_t enterTime, exitTime;
     getIPSParms(ipsEnabled, enterUtil, enterTime, exitUtil, exitTime);
 
-    log<level::INFO>(
-        std::format(
-            "Idle Power Saver Parameters: enabled:{}, enter:{}%/{}s, exit:{}%/{}s",
-            ipsEnabled, enterUtil, enterTime, exitUtil, exitTime)
-            .c_str());
+    lg2::info(
+        "Idle Power Saver Parameters: enabled:{ENABLE}, enter:{EUTIL}%/{ETIME}s, exit:{XUTIL}%/{XTIME}s",
+        "ENABLE", ipsEnabled, "EUTIL", enterUtil, "ETIME", enterTime, "XUTIL",
+        exitUtil, "XTIME", exitTime);
 
     std::vector<std::uint8_t> cmd, rsp;
     cmd.reserve(12);
@@ -771,10 +741,9 @@
     cmd.push_back(exitTime >> 8);      // Exit Delay Time
     cmd.push_back(exitTime & 0xFF);    //
     cmd.push_back(exitUtil);           // Exit Utilization
-    log<level::INFO>(std::format("PowerMode::sendIpsData: SET_CFG_DATA[IPS] "
-                                 "command to OCC{} ({} bytes)",
-                                 occInstance, cmd.size())
-                         .c_str());
+    lg2::info("PowerMode::sendIpsData: SET_CFG_DATA[IPS] "
+              "command to OCC{INST} ({LEN} bytes)",
+              "INST", occInstance, "LEN", cmd.size());
     CmdStatus status = occCmd->send(cmd, rsp);
     if (status == CmdStatus::SUCCESS)
     {
@@ -786,18 +755,16 @@
             }
             else
             {
-                log<level::ERR>(
-                    std::format(
-                        "PowerMode::sendIpsData: SET_CFG_DATA[IPS] failed with status 0x{:02X}",
-                        rsp[2])
-                        .c_str());
+                lg2::error(
+                    "PowerMode::sendIpsData: SET_CFG_DATA[IPS] failed with status {STATUS}",
+                    "STATUS", lg2::hex, rsp[2]);
                 dump_hex(rsp);
                 status = CmdStatus::FAILURE;
             }
         }
         else
         {
-            log<level::ERR>(
+            lg2::error(
                 "PowerMode::sendIpsData: INVALID SET_CFG_DATA[IPS] response");
             dump_hex(rsp);
             status = CmdStatus::FAILURE;
@@ -805,11 +772,9 @@
     }
     else
     {
-        log<level::ERR>(
-            std::format(
-                "PowerMode::sendIpsData: SET_CFG_DATA[IPS] with status={}",
-                status)
-                .c_str());
+        lg2::error(
+            "PowerMode::sendIpsData: SET_CFG_DATA[IPS] with status={STATUS}",
+            "STATUS", lg2::hex, uint8_t(status));
     }
 
     return status;
@@ -820,22 +785,19 @@
 {
     if (modeData.modeInitialized)
     {
-        log<level::INFO>(
-            std::format(
-                "OccPersistData: Mode: 0x{:02X}, OEM Mode Data: {} (0x{:04X} Locked{})",
-                modeData.mode, modeData.oemModeData, modeData.oemModeData,
-                modeData.modeLocked)
-                .c_str());
+        lg2::info(
+            "OccPersistData: Mode: {MODE}, OEM Mode Data: {DATA} ({DATAHEX} Locked{LOCK})",
+            "MODE", lg2::hex, uint8_t(modeData.mode), "DATA",
+            modeData.oemModeData, "DATAHEX", lg2::hex, modeData.oemModeData,
+            "LOCK", modeData.modeLocked);
     }
     if (modeData.ipsInitialized)
     {
-        log<level::INFO>(
-            std::format(
-                "OccPersistData: IPS enabled:{}, enter:{}%/{}s, exit:{}%/{}s",
-                modeData.ipsEnabled, modeData.ipsEnterUtil,
-                modeData.ipsEnterTime, modeData.ipsExitUtil,
-                modeData.ipsExitTime)
-                .c_str());
+        lg2::info(
+            "OccPersistData: IPS enabled:{ENABLE}, enter:{EUTIL}%/{ETIME}s, exit:{XUTIL}%/{XTIME}s",
+            "ENABLE", modeData.ipsEnabled, "EUTIL", modeData.ipsEnterUtil,
+            "ETIME", modeData.ipsEnterTime, "XUTIL", modeData.ipsExitUtil,
+            "XTIME", modeData.ipsExitTime);
     }
 }
 
@@ -850,11 +812,9 @@
         std::filesystem::create_directory(opath.parent_path());
     }
 
-    log<level::DEBUG>(
-        std::format(
-            "OccPersistData::save: Writing Power Mode persisted data to {}",
-            opath.c_str())
-            .c_str());
+    lg2::debug(
+        "OccPersistData::save: Writing Power Mode persisted data to {FILE}",
+        "FILE", opath);
     // print();
 
     std::ofstream stream{opath.c_str()};
@@ -876,11 +836,9 @@
         return;
     }
 
-    log<level::DEBUG>(
-        std::format(
-            "OccPersistData::load: Reading Power Mode persisted data from {}",
-            ipath.c_str())
-            .c_str());
+    lg2::debug(
+        "OccPersistData::load: Reading Power Mode persisted data from {FILE}",
+        "FILE", ipath);
     try
     {
         std::ifstream stream{ipath.c_str()};
@@ -890,10 +848,8 @@
     catch (const std::exception& e)
     {
         auto error = errno;
-        log<level::ERR>(
-            std::format("OccPersistData::load: failed to read {}, errno={}",
-                        ipath.c_str(), error)
-                .c_str());
+        lg2::error("OccPersistData::load: failed to read {FILE}, errno={ERR}",
+                   "FILE", ipath, "ERR", error);
         modeData.modeInitialized = false;
         modeData.ipsInitialized = false;
     }
@@ -916,11 +872,9 @@
         persistedData.getMode(pMode, oemModeData);
         if (!isValidMode(pMode))
         {
-            log<level::ERR>(
-                std::format(
-                    "defaultsReady: Persisted power mode ({}/{}) is not valid. Reading system default mode",
-                    pMode, oemModeData)
-                    .c_str());
+            lg2::error(
+                "defaultsReady: Persisted power mode ({MODE}/{DATA}) is not valid. Reading system default mode",
+                "MODE", pMode, "DATA", oemModeData);
             persistedData.invalidateMode();
         }
     }
@@ -928,12 +882,10 @@
     // If persistent data exists, then don't need to read defaults
     if ((!persistedData.modeAvailable()) || (!persistedData.ipsAvailable()))
     {
-        log<level::INFO>(
-            std::format(
-                "Default PowerModeProperties are now available (persistent modeAvail={}, ipsAvail={})",
-                persistedData.modeAvailable() ? 'y' : 'n',
-                persistedData.ipsAvailable() ? 'y' : 'n')
-                .c_str());
+        lg2::info(
+            "Default PowerModeProperties are now available (persistent modeAvail={MAVAIL}, ipsAvail={IAVAIL})",
+            "MAVAIL", persistedData.modeAvailable(), "IAVAIL",
+            persistedData.ipsAvailable());
 
         // Read default power mode defaults and update DBus
         initPersistentData();
@@ -964,10 +916,9 @@
         defaultMode = powermode::convertStringToMode(fullModeString);
         if (!VALID_POWER_MODE_SETTING(defaultMode))
         {
-            log<level::ERR>(std::format("PowerMode::getDefaultMode: Invalid "
-                                        "default power mode found: {}",
-                                        defaultMode)
-                                .c_str());
+            lg2::error("PowerMode::getDefaultMode: Invalid "
+                       "default power mode found: {MODE}",
+                       "MODE", defaultMode);
             // If default was read but not valid, use Max Performance
             defaultMode = SysPwrMode::MAX_PERF;
             return true;
@@ -975,9 +926,7 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format("Unable to read Default Power Mode: {}", e.what())
-                .c_str());
+        lg2::error("Unable to read Default Power Mode: {ERR}", "ERR", e.what());
         return false;
     }
 
@@ -1015,11 +964,9 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format(
-                "Unable to read Default Idle Power Saver parameters so it will be disabled: {}",
-                e.what())
-                .c_str());
+        lg2::error(
+            "Unable to read Default Idle Power Saver parameters so it will be disabled: {ERR}",
+            "ERR", e.what());
         return false;
     }
 
@@ -1030,7 +977,7 @@
     }
     else
     {
-        log<level::ERR>(
+        lg2::error(
             "PowerMode::getDefaultIPSParms could not find property: IdlePowerSaverEnabled");
     }
 
@@ -1041,7 +988,7 @@
     }
     else
     {
-        log<level::ERR>(
+        lg2::error(
             "PowerMode::getDefaultIPSParms could not find property: EnterUtilizationPercent");
     }
 
@@ -1052,7 +999,7 @@
     }
     else
     {
-        log<level::ERR>(
+        lg2::error(
             "PowerMode::getDefaultIPSParms could not find property: EnterUtilizationDwellTime");
     }
 
@@ -1063,7 +1010,7 @@
     }
     else
     {
-        log<level::ERR>(
+        lg2::error(
             "PowerMode::getDefaultIPSParms could not find property: ExitUtilizationPercent");
     }
 
@@ -1074,17 +1021,15 @@
     }
     else
     {
-        log<level::ERR>(
+        lg2::error(
             "PowerMode::getDefaultIPSParms could not find property: ExitUtilizationDwellTime");
     }
 
     if (enterUtil > exitUtil)
     {
-        log<level::ERR>(
-            std::format(
-                "ERROR: Default Idle Power Saver Enter Utilization ({}%) is > Exit Utilization ({}%) - using Exit for both",
-                enterUtil, exitUtil)
-                .c_str());
+        lg2::error(
+            "ERROR: Default Idle Power Saver Enter Utilization ({ENTER}%) is > Exit Utilization ({EXIT}%) - using Exit for both",
+            "ENTER", enterUtil, "EXIT", exitUtil);
         enterUtil = exitUtil;
     }
 
@@ -1105,11 +1050,11 @@
         // Unable to read defaults
         return false;
     }
-    log<level::INFO>(
-        std::format(
-            "PowerMode::useDefaultIPSParms: Using default IPS parms: Enabled: {}, EnterUtil: {}%, EnterTime: {}s, ExitUtil: {}%, ExitTime: {}s",
-            ipsEnabled, enterUtil, enterTime, exitUtil, exitTime)
-            .c_str());
+    lg2::info("PowerMode::useDefaultIPSParms: Using default IPS parms: "
+              "Enabled: {ENABLE}, EnterUtil: {EUTIL}%, EnterTime: {ETIME}s, "
+              "ExitUtil: {XUTIL}%, ExitTime: {XTIME}s",
+              "ENABLE", ipsEnabled, "EUTIL", enterUtil, "ETIME", enterTime,
+              "XUTIL", exitUtil, "XTIME", exitTime);
 
     // Save IPS parms to the persistent file
     persistedData.updateIPS(ipsEnabled, enterUtil, enterTime, exitUtil,
@@ -1127,10 +1072,9 @@
     const int open_errno = errno;
     if (fd < 0)
     {
-        log<level::ERR>(
-            std::format("openIpsFile Error({})={} : File={}", open_errno,
-                        strerror(open_errno), ipsStatusFile.c_str())
-                .c_str());
+        lg2::error("openIpsFile Error({ERR})={STR} : File={FILE}", "ERR",
+                   open_errno, "STR", strerror(open_errno), "FILE",
+                   ipsStatusFile);
 
         close(fd);
 
@@ -1201,9 +1145,8 @@
                              ipsStatusCallBack, this);
     if (r < 0)
     {
-        log<level::ERR>(std::format("sd_event_add_io: Error({})={} : File={}",
-                                    r, strerror(-r), ipsStatusFile.c_str())
-                            .c_str());
+        lg2::error("sd_event_add_io: Error({ERR})={STR} : File={FILE}", "ERR",
+                   r, "STR", strerror(-r), "FILE", ipsStatusFile);
 
         using InternalFailure =
             sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
@@ -1261,11 +1204,10 @@
         {
             removeIpsWatch();
 
-            log<level::ERR>(
-                std::format("IPS state Read Error({})={} : File={} : len={}",
-                            readErrno, strerror(readErrno),
-                            ipsStatusFile.c_str(), len)
-                    .c_str());
+            lg2::error(
+                "IPS state Read Error({ERR})={STR} : File={FILE} : len={LEN}",
+                "ERR", readErrno, "STR", strerror(readErrno), "FILE",
+                ipsStatusFile, "LEN", len);
 
             report<ReadFailure>(
                 phosphor::logging::org::open_power::OCC::Device::ReadFailure::
@@ -1301,10 +1243,9 @@
 
         // If the Retry did not get to "watching = true" we already have an
         // error log, just post trace.
-        log<level::ERR>(
-            std::format("Retry on File seek Error({})={} : File={}", open_errno,
-                        strerror(open_errno), ipsStatusFile.c_str())
-                .c_str());
+        lg2::error("Retry on File seek Error({ERR})={STR} : File={FILE}", "ERR",
+                   open_errno, "STR", strerror(open_errno), "FILE",
+                   ipsStatusFile);
 
         // NOTE: this will leave the system not reporting IPS active state to
         // Fan Controls, Until an APP reload, or IPL and we will attempt again.
@@ -1318,7 +1259,7 @@
 {
     if (persistedData.getModeLock())
     {
-        log<level::INFO>("PowerMode::powerMode: mode property change blocked");
+        lg2::info("PowerMode::powerMode: mode property change blocked");
         elog<NotAllowed>(xyz::openbmc_project::Common::NotAllowed::REASON(
             "mode change not allowed due to lock"));
     }
@@ -1336,10 +1277,8 @@
                 // Update persisted data with new mode
                 persistedData.updateMode(newMode, 0);
 
-                log<level::INFO>(
-                    std::format("DBus PowerMode Changed: {}",
-                                convertPowerModeToString(requestedMode))
-                        .c_str());
+                lg2::info("DBus PowerMode Changed: {MODE}", "MODE",
+                          convertPowerModeToString(requestedMode));
 
                 // Send mode change to OCC
                 sendModeChange();
@@ -1347,11 +1286,9 @@
             else
             {
                 // Not Allowed
-                log<level::ERR>(
-                    std::format(
-                        "PowerMode change not allowed. {} is not in AllowedPowerModes",
-                        convertPowerModeToString(requestedMode))
-                        .c_str());
+                lg2::error(
+                    "PowerMode change not allowed. {MODE} is not in AllowedPowerModes",
+                    "MODE", convertPowerModeToString(requestedMode));
                 elog<NotAllowed>(
                     xyz::openbmc_project::Common::NotAllowed::REASON(
                         "PowerMode value not allowed"));
@@ -1363,11 +1300,9 @@
             using InvalidArgument =
                 sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument;
             using Argument = xyz::openbmc_project::Common::InvalidArgument;
-            log<level::ERR>(
-                std::format(
-                    "PowerMode not valid. {} is not in AllowedPowerModes",
-                    convertPowerModeToString(requestedMode))
-                    .c_str());
+            lg2::error(
+                "PowerMode not valid. {MODE} is not in AllowedPowerModes",
+                "MODE", convertPowerModeToString(requestedMode));
             elog<InvalidArgument>(Argument::ARGUMENT_NAME("PowerMode"),
                                   Argument::ARGUMENT_VALUE("INVALID MODE"));
         }
@@ -1382,10 +1317,8 @@
  */
 void PowerMode::updateDbusSafeMode(const bool safeModeReq)
 {
-    log<level::DEBUG>(
-        std::format("PowerMode:updateDbusSafeMode: Update dbus state ({})",
-                    safeModeReq)
-            .c_str());
+    lg2::debug("PowerMode:updateDbusSafeMode: Update dbus state ({STATE})",
+               "STATE", safeModeReq);
 
     // Note; this function checks and only updates if different.
     Mode::safeMode(safeModeReq);
@@ -1415,9 +1348,8 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(
-            std::format("Unable to read PowerModeProperties: {}", e.what())
-                .c_str());
+        lg2::error("Unable to read PowerModeProperties: {ERR}", "ERR",
+                   e.what());
         return false;
     }
 
@@ -1426,9 +1358,8 @@
     if (ecoSupport != powerModeProperties.end())
     {
         ecoModeSupport = std::get<bool>(ecoSupport->second);
-        log<level::INFO>(std::format("getSupportedModes(): ecoModeSupport: {}",
-                                     ecoModeSupport)
-                             .c_str());
+        lg2::info("getSupportedModes(): ecoModeSupport: {SUPPORT}", "SUPPORT",
+                  ecoModeSupport);
     }
 
     // Determine what customer modes are supported
@@ -1443,8 +1374,7 @@
             // Ensure mode is valid
             const std::string fullModeString =
                 PMODE_INTERFACE + ".PowerMode."s + mode;
-            log<level::INFO>(
-                std::format("getSupportedModes(): {}", mode).c_str());
+            lg2::info("getSupportedModes(): {MODE}", "MODE", mode);
             SysPwrMode modeValue =
                 powermode::convertStringToMode(fullModeString);
             if (VALID_POWER_MODE_SETTING(modeValue))
@@ -1464,11 +1394,9 @@
             }
             else
             {
-                log<level::ERR>(
-                    std::format(
-                        "getSupportedModes(): Ignoring unsupported customer mode {}",
-                        mode)
-                        .c_str());
+                lg2::error(
+                    "getSupportedModes(): Ignoring unsupported customer mode {MODE}",
+                    "MODE", mode);
             }
         }
     }
@@ -1504,11 +1432,9 @@
             }
             else
             {
-                log<level::ERR>(
-                    std::format(
-                        "getSupportedModes(): Ignoring unsupported OEM mode {}",
-                        mode)
-                        .c_str());
+                lg2::error(
+                    "getSupportedModes(): Ignoring unsupported OEM mode {MODE}",
+                    "MODE", mode);
             }
         }
     }
diff --git a/utils.cpp b/utils.cpp
index bb9743b..efb7abd 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -4,12 +4,12 @@
 #include <unistd.h>
 
 #include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/lg2.hpp>
 #include <sdbusplus/bus.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/State/Boot/Progress/server.hpp>
 #include <xyz/openbmc_project/State/Host/server.hpp>
 
-#include <format>
 #include <string>
 namespace open_power
 {
@@ -42,9 +42,8 @@
     mapperResponseMsg.read(mapperResponse);
     if (mapperResponse.empty())
     {
-        log<level::ERR>("ERROR reading mapper response",
-                        entry("PATH=%s", path.c_str()),
-                        entry("INTERFACE=%s", interface.c_str()));
+        lg2::error("ERROR reading mapper response: path={PATH}, I/F={INTF}",
+                   "PATH", path, "INTF", interface);
 
         elog<InternalFailure>();
     }
@@ -106,19 +105,15 @@
         auto reply = bus.call(method);
         if (reply.is_method_error())
         {
-            log<level::ERR>(
-                std::format("util::setProperty: Failed to set property {}",
-                            propertyName)
-                    .c_str());
+            lg2::error("util::setProperty: Failed to set property {PROP}",
+                       "PROP", propertyName);
         }
     }
     catch (const std::exception& e)
     {
         auto error = errno;
-        log<level::ERR>(
-            std::format("setProperty: failed to Set {}, errno={}, what={}",
-                        propertyName.c_str(), error, e.what())
-                .c_str());
+        lg2::error("setProperty: failed to Set {PROP}, errno={ERR}, what={MSG}",
+                   "PROP", propertyName, "ERR", error, "PROP", e.what());
     }
 }
 
@@ -159,11 +154,9 @@
     mapperResponseMsg.read(rspObjects);
     if (rspObjects.empty())
     {
-        log<level::ERR>(
-            std::format(
-                "util::getServiceUsingSubTree: Failed getSubTree({},0,{})",
-                path.c_str(), interface)
-                .c_str());
+        lg2::error(
+            "util::getServiceUsingSubTree: Failed getSubTree({PATH},0,{INTF})",
+            "PATH", path, "INTF", interface);
     }
     else
     {
@@ -174,11 +167,9 @@
         }
         else
         {
-            log<level::ERR>(
-                std::format(
-                    "getServiceUsingSubTree: service not found for interface {} (path={})",
-                    interface, path.c_str())
-                    .c_str());
+            lg2::error(
+                "getServiceUsingSubTree: service not found for interface {INTF} (path={PATH})",
+                "INTF", interface, "PATH", path);
         }
     }
 
@@ -214,19 +205,18 @@
     }
     catch (const sdbusplus::exception_t& e)
     {
-        log<level::ERR>(std::format("D-Bus call exception, OBJPATH({}), "
-                                    "INTERFACE({}), PROPERTY({}) EXCEPTION({})",
-                                    objPath, intf, state, e.what())
-                            .c_str());
+        lg2::error("D-Bus call exception, OBJPATH({PATH}), "
+                   "INTERFACE({INTF}), PROPERTY({PROP}) EXCEPTION({ERR})",
+                   "PATH", objPath, "INTF", intf, "PROP", state, "ERR",
+                   e.what());
         throw std::runtime_error("Failed to get host state property");
     }
     catch (const std::bad_variant_access& e)
     {
-        log<level::ERR>(
-            std::format("Exception raised while read host state({}) property "
-                        "value,  OBJPATH({}), INTERFACE({}), EXCEPTION({})",
-                        state, objPath, intf, e.what())
-                .c_str());
+        lg2::error(
+            "Exception raised while read host state({STATE}) property "
+            "value,  OBJPATH({PATH}), INTERFACE({INTF}), EXCEPTION({ERR})",
+            "STATE", state, "PATH", objPath, "INTF", intf, "ERR", e.what());
         throw std::runtime_error("Failed to get host state property");
     }
 
