Ticket T154369
Visible to All Users

How to log operations with persistent objects

created 10 years ago

[DevExpress Support Team: CLONED FROM T154290: XPO Action Logging]
Is there a way for me to log Model or View-Model actions through XPO without fully implementing my own mechanism.

For example, I'd like to to log changes (creation, deletion, updates) of a Person persistent object. I don't want to track specific sql queries.

Regards.

Answers approved by DevExpress Support

created 10 years ago

Hello Milan,

You can reuse the logging functionality implemented for our XPO Profiler. Here is an example:

C#
DevExpress.Xpo.Logger.LoggerBase logger = new DevExpress.Xpo.Logger.LoggerBase(10000); DevExpress.Xpo.Logger.LogManager.SetTransport(logger); ... IEnumerable<LogMessage> logWithoutQueries = logger.GetCompleteLog().Where<LogMessage>(m => m.MessageType != LogMessageType.DbCommand);

Then parse the LogMessage objects and write them to the log file in the required format. Refer to the How to create a XPO logger similar to what XPO Profiler ticket for additional information.

If the output of our logger does not meet your needs, you can either log operations in the appropriate methods of your persistent classes, e.g. AfterConstruction, OnLoaded, OnChanged, etc., or handle events of Sessions used in your application, e.g. Session.ObjectChanged, Session.ObjectLoaded, etc.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.