diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 34625d3..f2a5722 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -18,6 +18,7 @@
 #include "app.hpp"
 #include "dbus_utility.hpp"
 #include "error_messages.hpp"
+#include "generated/enums/log_entry.hpp"
 #include "gzfile.hpp"
 #include "http_utility.hpp"
 #include "human_sort.hpp"
@@ -308,9 +309,31 @@
     return !redfishLogFiles.empty();
 }
 
+inline log_entry::OriginatorTypes
+    mapDbusOriginatorTypeToRedfish(const std::string& originatorType)
+{
+    if (originatorType ==
+        "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.Client")
+    {
+        return log_entry::OriginatorTypes::Client;
+    }
+    if (originatorType ==
+        "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.Internal")
+    {
+        return log_entry::OriginatorTypes::Internal;
+    }
+    if (originatorType ==
+        "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.SupportingService")
+    {
+        return log_entry::OriginatorTypes::SupportingService;
+    }
+    return log_entry::OriginatorTypes::Invalid;
+}
+
 inline void parseDumpEntryFromDbusObject(
     const dbus::utility::ManagedObjectType::value_type& object,
     std::string& dumpStatus, uint64_t& size, uint64_t& timestampUs,
+    std::string& originatorId, log_entry::OriginatorTypes& originatorType,
     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
 {
     for (const auto& interfaceMap : object.second)
@@ -368,6 +391,42 @@
                 }
             }
         }
+        else if (interfaceMap.first ==
+                 "xyz.openbmc_project.Common.OriginatedBy")
+        {
+            for (const auto& propertyMap : interfaceMap.second)
+            {
+                if (propertyMap.first == "OriginatorId")
+                {
+                    const std::string* id =
+                        std::get_if<std::string>(&propertyMap.second);
+                    if (id == nullptr)
+                    {
+                        messages::internalError(asyncResp->res);
+                        break;
+                    }
+                    originatorId = *id;
+                }
+
+                if (propertyMap.first == "OriginatorType")
+                {
+                    const std::string* type =
+                        std::get_if<std::string>(&propertyMap.second);
+                    if (type == nullptr)
+                    {
+                        messages::internalError(asyncResp->res);
+                        break;
+                    }
+
+                    originatorType = mapDbusOriginatorTypeToRedfish(*type);
+                    if (originatorType == log_entry::OriginatorTypes::Invalid)
+                    {
+                        messages::internalError(asyncResp->res);
+                        break;
+                    }
+                }
+            }
+        }
     }
 }
 
@@ -453,6 +512,9 @@
             uint64_t timestampUs = 0;
             uint64_t size = 0;
             std::string dumpStatus;
+            std::string originatorId;
+            log_entry::OriginatorTypes originatorType =
+                log_entry::OriginatorTypes::Internal;
             nlohmann::json::object_t thisEntry;
 
             std::string entryID = object.first.filename();
@@ -462,6 +524,7 @@
             }
 
             parseDumpEntryFromDbusObject(object, dumpStatus, size, timestampUs,
+                                         originatorId, originatorType,
                                          asyncResp);
 
             if (dumpStatus !=
@@ -472,7 +535,7 @@
                 continue;
             }
 
-            thisEntry["@odata.type"] = "#LogEntry.v1_9_0.LogEntry";
+            thisEntry["@odata.type"] = "#LogEntry.v1_11_0.LogEntry";
             thisEntry["@odata.id"] = entriesPath + entryID;
             thisEntry["Id"] = entryID;
             thisEntry["EntryType"] = "Event";
@@ -480,6 +543,12 @@
             thisEntry["Created"] =
                 redfish::time_utils::getDateTimeUintUs(timestampUs);
 
+            if (!originatorId.empty())
+            {
+                thisEntry["Originator"] = originatorId;
+                thisEntry["OriginatorType"] = originatorType;
+            }
+
             if (dumpType == "BMC")
             {
                 thisEntry["DiagnosticDataType"] = "Manager";
@@ -541,9 +610,13 @@
             uint64_t timestampUs = 0;
             uint64_t size = 0;
             std::string dumpStatus;
+            std::string originatorId;
+            log_entry::OriginatorTypes originatorType =
+                log_entry::OriginatorTypes::Internal;
 
             parseDumpEntryFromDbusObject(objectPath, dumpStatus, size,
-                                         timestampUs, asyncResp);
+                                         timestampUs, originatorId,
+                                         originatorType, asyncResp);
 
             if (dumpStatus !=
                     "xyz.openbmc_project.Common.Progress.OperationStatus.Completed" &&
@@ -557,7 +630,7 @@
             }
 
             asyncResp->res.jsonValue["@odata.type"] =
-                "#LogEntry.v1_9_0.LogEntry";
+                "#LogEntry.v1_11_0.LogEntry";
             asyncResp->res.jsonValue["@odata.id"] = entriesPath + entryID;
             asyncResp->res.jsonValue["Id"] = entryID;
             asyncResp->res.jsonValue["EntryType"] = "Event";
@@ -565,6 +638,12 @@
             asyncResp->res.jsonValue["Created"] =
                 redfish::time_utils::getDateTimeUintUs(timestampUs);
 
+            if (!originatorId.empty())
+            {
+                asyncResp->res.jsonValue["Originator"] = originatorId;
+                asyncResp->res.jsonValue["OriginatorType"] = originatorType;
+            }
+
             if (dumpType == "BMC")
             {
                 asyncResp->res.jsonValue["DiagnosticDataType"] = "Manager";
@@ -867,6 +946,13 @@
     std::vector<std::pair<std::string, std::variant<std::string, uint64_t>>>
         createDumpParamVec;
 
+    createDumpParamVec.emplace_back(
+        "xyz.openbmc_project.Dump.Create.CreateParameters.OriginatorId",
+        req.session->clientIp);
+    createDumpParamVec.emplace_back(
+        "xyz.openbmc_project.Dump.Create.CreateParameters.OriginatorType",
+        "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.Client");
+
     crow::connections::systemBus->async_method_call(
         [asyncResp, payload(task::Payload(req)),
          dumpPath](const boost::system::error_code& ec,
