Service Logging
Journey Manager provides a central Groovy Service Logging facility for operational support and system testing. This facility is extremely useful for monitoring and trouble shooting integration with remote services. To use this navigate to Services > Groovy Service Log in your Journey Manager environment.
By default, all Groovy service invocations are logged. To disable Groovy service logging, edit the Service Definition and set the groovyLoggingEnabled parameter to false
.
There is also a system level deployment property Groovy Logging Enabled which specifies whether Groovy service logging is enabled if a Service Definition does not specify the groovyLoggingEnabled parameter. This is relevant for Service Definitions created before Transact Manager version 4.2 which did not have this Service Parameter.
Groovy Logger
Journey Manager also provides a GroovyLogger
object that you can use to log messages from inside your Groovy scripts. This is extremely easy to do, and you should use this when developing scripts and debugging operational issues. For example:
import com.avoka.core.groovy.GroovyLogger as logger
import com.avoka.tm.vo.*
import javax.servlet.http.*
class LoggingUserData {
String invoke(SvcDef svcDef, Txn txn, HttpServletRequest request, User user) {
// Get user token cookie
def userToken = ...
logger.info 'user token:' + userToken
// Load user account
def account = ...
logger.info 'loaded user account:' + account.id
// Load user profile
def profile = ...
logger.info 'loaded user profile:' + profile.email
}
}
When your Groovy service is run, these logger messages will be associated with the Groovy Service Log record. In the Groovy Service Log, you can click the Groovy Log Message action icon to see logger messages.
This allow you to view script execution logging messages without having to access the server log files. It is also much easier to read the logger messages of your call thread compared to reading server log files where there are many threads writing to the file at the same time.
Debug Logging
When a Groovy service executes without any errors, all INFO, WARN and ERROR level messages are logged, but DEBUG messages aren't. If the Groovy service throws an exception, however, all logging messages including DEBUG level are logged. The rationale for this behaviour is when an error occurs you need all the information available to diagnose the issue, while during normal execution you only need to log INFO level messages.
tip
Debug logging is an extremely useful capability. Insert DEBUG logger messages in your script at the points where you want to record details to help diagnose any operational issues.
If you need to override this default behavior and log all DEBUG level messages, set the Groovy Debug Logging service parameter to true
.
This is a handy feature to diagnose operational issues. Turn on debug logging to identify the issue, then turn if off once the issue has been resolved.
Server Log File
When Groovy scripts are being executed, these logger statements are written to the server log file server/standalone/log/server.log
. For example:
21:42:54,792 INFO [com.avoka.fc.core.service.TransactionProcessor] (TM_Worker-1) Transaction Processor completed in 0 sec.
<span style="color:red">21:43:35,312 ERROR [com.avoka.core.groovy.GroovyLogger] (pool-32-thread-1) java.lang.NumberFormatException: For input string: "12,3"</span>
21:47:54,795 INFO [com.avoka.fc.core.service.TransactionProcessor] (TM_Worker-5) Transaction Processor completed in 0 sec.
In this example, the logger.info
statements were not logged to the server log file. This is because the Log4J GroovyLogger category logging level is set to WARN which means WARN and ERROR messages are logged, but DEBUG and INFO messages aren't.
You can change this in the configuration file server/standalone/configuration/standalone.xml
.
<logger category="com.avoka.core.groovy.GroovyLogger">
<level name="WARN"/>
</logger>
Logging Sensitive Data
note
These script execution log messages are stored in the database and in the server log file in clear text, so don't log any information which is highly sensitive and should be encrypted. For example, don't do this:
logger.info "Form Data: " + submissionXml
If you do need to record additional sensitive data against a transaction, create an encrypted SubmissionProperty
record and associate it with the transaction Submission
.
Logging HTTP Requests
The GroovyLogger
provides special support for logging HttpServletRequest
objects.
import com.avoka.core.groovy.GroovyLogger as logger
import com.avoka.tm.vo.*
import javax.servlet.http.*
class LoggingRequestData {
String invoke(SvcDef svcDef, Txn txn, HttpServletRequest request, User user) {
logger.info request
//...
}
}
The Groovy script above logs the service request output shown below.