Logger to Trace Rule

Which IIQ version are you inquiring about?

Version 8.2

Share all details related to your problem, including any error messages you may have received.

I am troubleshooting an error with a custom rule that was created before I started this position. This was created with Log4j implemented, but I’m not sure how I can create/use an existing logger to trace what is happening in this rule. I see the below line in the rule, not sure if this is used as the logger itself:

private static Log logger = LogFactory.getLog(“rule.approval.assignment”);

You can just put eg. logger.debug(“Some debug message”) into place where you want to log something.

Don’t forget to enable logger in log4j.properties file

1 Like

hey @Alyson_Trad , you just need to update the Log4j2 propertiesd files.

The string between the quotes “rule.approval.assignment” is the class Logger Name.

So you just need to create the logger for it on the properties file.

best!

1 Like

Hi @Alyson_Trad,

Logger name mentioned in quote is the class name and it should have entry in your log4j2 properties(present in WEB-INF\classes) if it was a working snippet. So, for the same you can get the log file name from this log4j2.properties file or depending upon configuration it may be printing details in primary log file also.

Thanks

1 Like

@Alyson_Trad
You can also configure the log level directly in the rule (no need to update the log4j2.properties file)

import org.apache.log4j.*;

private static org.apache.log4j.Logger log = Logger.getLogger(rule.approval.assignment);
log.setLevel(Level.WARN);

//This will print all info and Warn.
1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.