Question
· Jul 21

How do I write errors to the Application Error Log?

I am trying to catch an exception and write it to the Application Error Log, but cant find any details on how to do this in IRIS health.

        Catch ex {
            Set logger = ##class(%Logger).%GetLogger("MyApp")
            Do logger.Error($ZError)
        }

Cant seem to find the %Logger class either.

Product version: IRIS 2024.1
$ZV: IRIS for UNIX (Red Hat Enterprise Linux 8 for x86-64) 2024.1.2 (Build 398_0_23819) Wed Nov 20 2024 18:24:21 EST
Discussion (3)3
Log in or sign up to continue

To log an exception to the Application Error Log in InterSystems IRIS, you should use the %Exception.AbstractException.Log() method. Typically, this is done within the CATCH block of a TRY-CATCH construct. Here is an example in ObjectScript demonstrating this approach:

TRY {
    // Code that might throw an exception
} 
CATCH ex {
    // Log the caught exception to the Application Error Log
    DO ex.Log()
}

This method ensures that the details of the exception, including its type and properties, are recorded in the namespace-specific Application Error Log [1].

Sources: