diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp
index 4ecc436..2682717 100644
--- a/include/dbus_monitor.hpp
+++ b/include/dbus_monitor.hpp
@@ -36,7 +36,7 @@
 {
     if (retError == nullptr || (sd_bus_error_is_set(retError) != 0))
     {
-        BMCWEB_LOG_ERROR << "Got sdbus error on match";
+        BMCWEB_LOG_ERROR("Got sdbus error on match");
         return 0;
     }
     crow::websocket::Connection* connection =
@@ -44,7 +44,8 @@
     auto thisSession = sessions.find(connection);
     if (thisSession == sessions.end())
     {
-        BMCWEB_LOG_ERROR << "Couldn't find dbus connection " << connection;
+        BMCWEB_LOG_ERROR("Couldn't find dbus connection {}",
+                         logPtr(connection));
         return 0;
     }
     sdbusplus::message_t message(m);
@@ -57,12 +58,12 @@
         int r = openbmc_mapper::convertDBusToJSON("sa{sv}as", message, data);
         if (r < 0)
         {
-            BMCWEB_LOG_ERROR << "convertDBusToJSON failed with " << r;
+            BMCWEB_LOG_ERROR("convertDBusToJSON failed with {}", r);
             return 0;
         }
         if (!data.is_array())
         {
-            BMCWEB_LOG_ERROR << "No data in PropertiesChanged signal";
+            BMCWEB_LOG_ERROR("No data in PropertiesChanged signal");
             return 0;
         }
 
@@ -76,13 +77,13 @@
         int r = openbmc_mapper::convertDBusToJSON("oa{sa{sv}}", message, data);
         if (r < 0)
         {
-            BMCWEB_LOG_ERROR << "convertDBusToJSON failed with " << r;
+            BMCWEB_LOG_ERROR("convertDBusToJSON failed with {}", r);
             return 0;
         }
 
         if (!data.is_array())
         {
-            BMCWEB_LOG_ERROR << "No data in InterfacesAdded signal";
+            BMCWEB_LOG_ERROR("No data in InterfacesAdded signal");
             return 0;
         }
 
@@ -98,8 +99,7 @@
     }
     else
     {
-        BMCWEB_LOG_CRITICAL << "message " << message.get_member()
-                            << " was unexpected";
+        BMCWEB_LOG_CRITICAL("message {} was unexpected", message.get_member());
         return 0;
     }
 
@@ -114,140 +114,140 @@
         .privileges({{"Login"}})
         .websocket()
         .onopen([&](crow::websocket::Connection& conn) {
-            BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
+            BMCWEB_LOG_DEBUG("Connection {} opened", logPtr(&conn));
             sessions.try_emplace(&conn);
         })
         .onclose([&](crow::websocket::Connection& conn, const std::string&) {
             sessions.erase(&conn);
         })
-        .onmessage(
-            [&](crow::websocket::Connection& conn, const std::string& data,
-                bool) {
-        const auto sessionPair = sessions.find(&conn);
-        if (sessionPair == sessions.end())
-        {
-            conn.close("Internal error");
-        }
-        DbusWebsocketSession& thisSession = sessionPair->second;
-        BMCWEB_LOG_DEBUG << "Connection " << &conn << " received " << data;
-        nlohmann::json j = nlohmann::json::parse(data, nullptr, false);
-        if (j.is_discarded())
-        {
-            BMCWEB_LOG_ERROR << "Unable to parse json data for monitor";
-            conn.close("Unable to parse json request");
-            return;
-        }
-        nlohmann::json::iterator interfaces = j.find("interfaces");
-        if (interfaces != j.end())
-        {
-            thisSession.interfaces.reserve(interfaces->size());
-            for (auto& interface : *interfaces)
+        .onmessage([&](crow::websocket::Connection& conn,
+                       const std::string& data, bool) {
+            const auto sessionPair = sessions.find(&conn);
+            if (sessionPair == sessions.end())
             {
-                const std::string* str =
-                    interface.get_ptr<const std::string*>();
-                if (str != nullptr)
+                conn.close("Internal error");
+            }
+            DbusWebsocketSession& thisSession = sessionPair->second;
+            BMCWEB_LOG_DEBUG("Connection {} received {}", logPtr(&conn), data);
+            nlohmann::json j = nlohmann::json::parse(data, nullptr, false);
+            if (j.is_discarded())
+            {
+                BMCWEB_LOG_ERROR("Unable to parse json data for monitor");
+                conn.close("Unable to parse json request");
+                return;
+            }
+            nlohmann::json::iterator interfaces = j.find("interfaces");
+            if (interfaces != j.end())
+            {
+                thisSession.interfaces.reserve(interfaces->size());
+                for (auto& interface : *interfaces)
                 {
-                    thisSession.interfaces.insert(*str);
+                    const std::string* str =
+                        interface.get_ptr<const std::string*>();
+                    if (str != nullptr)
+                    {
+                        thisSession.interfaces.insert(*str);
+                    }
                 }
             }
-        }
 
-        nlohmann::json::iterator paths = j.find("paths");
-        if (paths == j.end())
-        {
-            BMCWEB_LOG_ERROR << "Unable to find paths in json data";
-            conn.close("Unable to find paths in json data");
-            return;
-        }
-
-        size_t interfaceCount = thisSession.interfaces.size();
-        if (interfaceCount == 0)
-        {
-            interfaceCount = 1;
-        }
-        // Reserve our matches upfront.  For each path there is 1 for
-        // interfacesAdded, and InterfaceCount number for
-        // PropertiesChanged
-        thisSession.matches.reserve(thisSession.matches.size() +
-                                    paths->size() * (1U + interfaceCount));
-
-        // These regexes derived on the rules here:
-        // https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names
-        static std::regex validPath("^/([A-Za-z0-9_]+/?)*$");
-        static std::regex validInterface(
-            "^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)+$");
-
-        for (const auto& thisPath : *paths)
-        {
-            const std::string* thisPathString =
-                thisPath.get_ptr<const std::string*>();
-            if (thisPathString == nullptr)
+            nlohmann::json::iterator paths = j.find("paths");
+            if (paths == j.end())
             {
-                BMCWEB_LOG_ERROR << "subscribe path isn't a string?";
-                conn.close();
+                BMCWEB_LOG_ERROR("Unable to find paths in json data");
+                conn.close("Unable to find paths in json data");
                 return;
             }
-            if (!std::regex_match(*thisPathString, validPath))
-            {
-                BMCWEB_LOG_ERROR << "Invalid path name " << *thisPathString;
-                conn.close();
-                return;
-            }
-            std::string propertiesMatchString =
-                ("type='signal',"
-                 "interface='org.freedesktop.DBus.Properties',"
-                 "path_namespace='" +
-                 *thisPathString +
-                 "',"
-                 "member='PropertiesChanged'");
-            // If interfaces weren't specified, add a single match for all
-            // interfaces
-            if (thisSession.interfaces.empty())
-            {
-                BMCWEB_LOG_DEBUG << "Creating match " << propertiesMatchString;
 
-                thisSession.matches.emplace_back(
-                    std::make_unique<sdbusplus::bus::match_t>(
-                        *crow::connections::systemBus, propertiesMatchString,
-                        onPropertyUpdate, &conn));
-            }
-            else
+            size_t interfaceCount = thisSession.interfaces.size();
+            if (interfaceCount == 0)
             {
-                // If interfaces were specified, add a match for each
-                // interface
-                for (const std::string& interface : thisSession.interfaces)
+                interfaceCount = 1;
+            }
+            // Reserve our matches upfront.  For each path there is 1 for
+            // interfacesAdded, and InterfaceCount number for
+            // PropertiesChanged
+            thisSession.matches.reserve(thisSession.matches.size() +
+                                        paths->size() * (1U + interfaceCount));
+
+            // These regexes derived on the rules here:
+            // https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names
+            static std::regex validPath("^/([A-Za-z0-9_]+/?)*$");
+            static std::regex validInterface(
+                "^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)+$");
+
+            for (const auto& thisPath : *paths)
+            {
+                const std::string* thisPathString =
+                    thisPath.get_ptr<const std::string*>();
+                if (thisPathString == nullptr)
                 {
-                    if (!std::regex_match(interface, validInterface))
-                    {
-                        BMCWEB_LOG_ERROR << "Invalid interface name "
-                                         << interface;
-                        conn.close();
-                        return;
-                    }
-                    std::string ifaceMatchString = propertiesMatchString;
-                    ifaceMatchString += ",arg0='";
-                    ifaceMatchString += interface;
-                    ifaceMatchString += "'";
-                    BMCWEB_LOG_DEBUG << "Creating match " << ifaceMatchString;
+                    BMCWEB_LOG_ERROR("subscribe path isn't a string?");
+                    conn.close();
+                    return;
+                }
+                if (!std::regex_match(*thisPathString, validPath))
+                {
+                    BMCWEB_LOG_ERROR("Invalid path name {}", *thisPathString);
+                    conn.close();
+                    return;
+                }
+                std::string propertiesMatchString =
+                    ("type='signal',"
+                     "interface='org.freedesktop.DBus.Properties',"
+                     "path_namespace='" +
+                     *thisPathString +
+                     "',"
+                     "member='PropertiesChanged'");
+                // If interfaces weren't specified, add a single match for all
+                // interfaces
+                if (thisSession.interfaces.empty())
+                {
+                    BMCWEB_LOG_DEBUG("Creating match {}",
+                                     propertiesMatchString);
+
                     thisSession.matches.emplace_back(
                         std::make_unique<sdbusplus::bus::match_t>(
-                            *crow::connections::systemBus, ifaceMatchString,
-                            onPropertyUpdate, &conn));
+                            *crow::connections::systemBus,
+                            propertiesMatchString, onPropertyUpdate, &conn));
                 }
+                else
+                {
+                    // If interfaces were specified, add a match for each
+                    // interface
+                    for (const std::string& interface : thisSession.interfaces)
+                    {
+                        if (!std::regex_match(interface, validInterface))
+                        {
+                            BMCWEB_LOG_ERROR("Invalid interface name {}",
+                                             interface);
+                            conn.close();
+                            return;
+                        }
+                        std::string ifaceMatchString = propertiesMatchString;
+                        ifaceMatchString += ",arg0='";
+                        ifaceMatchString += interface;
+                        ifaceMatchString += "'";
+                        BMCWEB_LOG_DEBUG("Creating match {}", ifaceMatchString);
+                        thisSession.matches.emplace_back(
+                            std::make_unique<sdbusplus::bus::match_t>(
+                                *crow::connections::systemBus, ifaceMatchString,
+                                onPropertyUpdate, &conn));
+                    }
+                }
+                std::string objectManagerMatchString =
+                    ("type='signal',"
+                     "interface='org.freedesktop.DBus.ObjectManager',"
+                     "path_namespace='" +
+                     *thisPathString +
+                     "',"
+                     "member='InterfacesAdded'");
+                BMCWEB_LOG_DEBUG("Creating match {}", objectManagerMatchString);
+                thisSession.matches.emplace_back(
+                    std::make_unique<sdbusplus::bus::match_t>(
+                        *crow::connections::systemBus, objectManagerMatchString,
+                        onPropertyUpdate, &conn));
             }
-            std::string objectManagerMatchString =
-                ("type='signal',"
-                 "interface='org.freedesktop.DBus.ObjectManager',"
-                 "path_namespace='" +
-                 *thisPathString +
-                 "',"
-                 "member='InterfacesAdded'");
-            BMCWEB_LOG_DEBUG << "Creating match " << objectManagerMatchString;
-            thisSession.matches.emplace_back(
-                std::make_unique<sdbusplus::bus::match_t>(
-                    *crow::connections::systemBus, objectManagerMatchString,
-                    onPropertyUpdate, &conn));
-        }
         });
 }
 } // namespace dbus_monitor
