How to perform logging in the ERP?
It is very important to get information on the operations performed by the user to any transactional app. Using this record, we can detect potential problems, errors or even understand what is happening when the code is executed. The ERP log record mechanism was vastly improved to provide more information to the user and for this information to be loaded into Excel. This mechanism is in the assembly Primavera.Platform.Helpers, that you must reference in the projects you which to use this feature. The available methods belong to the class StdLoggingHandler and are the following: The method FileTraceIgnoredException must be used to record in the log the exceptions that will be ignored. It is possible to identify these records using the tag [IGNORED]. The method FileTraceWithThrow must be used when the exceptions are not going to be ignored and will be returned to the previous method. In this case, the log record is generated with the tag [THROWED]. The method FileTraceEnterMethod must be used at the start of the method execution (or function) to records its entry. The following log entries are indented in the file, returning to normal after invoking the method FileTraceExitMethod. When the log record mechanism is activated, a file is created using the name erp.log in the folder c:temp. When the mechanism is deactivated, the file is removed. This file can also be created manually in this folder, what automatically activates the mechanism when starting each ERP session. You can find several examples of use of these methods in this GitHub project.ActivateLog Activated the ERP log record without needing to restart the app DeactivateLog Disconnects the log record for the current ERP session ClearLogFile Clears the log file in runtime FileTrace Records a message defined by the developer FileTraceEnterMethod Records the entry in the invoking method (with or without message) FileTraceExitMethod Records the issue in the invoking method (with or without message) FileTraceFirstChanceException Record place in the handler of the ERP First Change Exception FileTraceIgnoredException Records the ignored exceptions FileTraceOnlyOnVerbose Only records the log if the mode verbose is active FileTraceVerbose Records in more detail the invoking stack FileTraceWithThrow Records exceptions that throw FullMessageFromException Records the total message of an exception (including inner exceptions) GetActiveLogContent Allows to view the log records GetActiveLogTail Allows to view the last n log records GetActiveLogFile Returns the active log file name Indent Indents (adds an initial tab) to the following log calls Outdent Removes the initial spacing FileTraceIgnoredException vs FileTraceWithThrow
FileTraceEnterMethod vs FileTraceExitMethod
ActivateLog vs. DeactivateLog
For the log record to work in mode verbose, the file name must be erp.verbose.log.
login para deixar a sua opinião.