Allow REST APIs errors don't be logged

Out of the scope

My idea is to have a similar mechanism that is done with Exception Handlers to REST APIs errors, this is, the ability to choose if we want to log the error or not.

For example, in the OnAfterResponse of a REST API I would like to don't log the exception that occurs when condition 2 is true.

This exception is logged with the module REST (Consume).

Created on 21 Sep 2018
Comments (8)

Additional information: when an explicit error is thrown in the OnAfterResponse (like in the example above), or when a non-200-series status code is received (like a "403 forbidden"), the Error Log always shows the Exception, with Module "REST (Consume)". Since these kind of Exceptions or status codes are expected, and are handled in the Action that calls the REST API Method (where the developer can choose to log an error or not in the Exception Handler), these messages pollute the Error Log, and should imho simply not be there (note that if they are not handled by the caller, two exception messages are logged, which is a bit superfluous anyway).

I'm facing the exact same problem.

The API that I'm using sends a status code 404 when they don't have information but for me, that's not an error. I just want to handle it differently from the status code 200 and not log the error. 

Right now I have service center filled with this 404 errors and I cannot easily identify the "real" errors of my factory.

Changed the category to Integration

Changed the status to
Out of the scope

Hi Patrícia, 

Thanks for your feedback.

On your code if you don't throw the exception and just replace it by an End node, it will not be logged on Service Center.

If you which to throw the exception and not log in service center you can catch the exception and choose the property Log Error set No.


Hi Fernando,

I encourage you to do the test yourself and see that it will log the error even with the property Log Error set No. 

I've tested this In version 10 and the only way I have for the platform not to log it as an error is to change the status code to '200' 

Hi Fernando,

Like Ricardo, I've also tested what you suggested (with expose APIs) and didn't work. 

Additionally, the solution you presented only applies to expose API where my problem was with consuming APIs.  

Either way, it doesn't work if I don't change the status code to '200' like Ricardo said which in my case is not possible since I want to handle the exception in another scope. 

Thanks for enlightenment, now I do understand the use case. 

What would be reason for not logging the error?

On Ricardo use case, the REST integration returns 404 when there is not information. But I guess, we all agree this is not a common or even best practice. With this kind of approach the consumer doesn't know if the service is down or was because there is no record to return. 

We should avoid this patterns and enforce good practices that allow our applications to be robust and provide accurate information to our users.

Patricia what is your use case for not wanting to have the log?

I would say returning a 404 on resource not found is the standard way to report this back, though "no information" is different from "resource not found", so perhaps you have something different in mind? Regardless, the way that the Platform currently handles error codes (both consuming and producing) is way under par, but that's for a different topic...