V10 ResourcesReference
ResourcesReference
Reference
Back | List of Articles

How to perform logging in the ERP?

Last changed in 02/07/2020

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:

ActivateLogActivated the ERP log record without needing to restart the app
DeactivateLogDisconnects the log record for the current ERP session
ClearLogFileClears the log file in runtime
FileTraceRecords a message defined by the developer
FileTraceEnterMethodRecords the entry in the invoking method (with or without message)
FileTraceExitMethodRecords the issue in the invoking method (with or without message)
FileTraceFirstChanceExceptionRecord place in the handler of the ERP First Change Exception
FileTraceIgnoredExceptionRecords the ignored exceptions
FileTraceOnlyOnVerboseOnly records the log if the mode verbose is active
FileTraceVerboseRecords in more detail the invoking stack
FileTraceWithThrowRecords exceptions that throw
FullMessageFromExceptionRecords the total message of an exception (including inner exceptions)
GetActiveLogContentAllows to view the log records
GetActiveLogTailAllows to view the last n log records
GetActiveLogFileReturns the active log file name
IndentIndents (adds an initial tab) to the following log calls
OutdentRemoves the initial spacing

FileTraceIgnoredException vs FileTraceWithThrow

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].

FileTraceEnterMethod vs FileTraceExitMethod

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.

ActivateLog vs. DeactivateLog

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.
For the log record to work in mode verbose, the file name must be erp.verbose.log.

You can find several examples of use of these methods in this GitHub project.

Bookmark or share this article
Esta página foi útil?
Obrigado pelo seu voto.

login para deixar a sua opinião.

Obrigado pelo seu feedback. Iremos analisá-lo para continuarmos a melhorar!
Artigos Relacionados
Características das entidades e serviços Conceito de integração Conceito de extensibilidade Como registar projetos de extensibilidade? Boas práticas de organização de projetos de integração