Hi all,
During our local process in CloverDX, we are trying to log custom created messages about the status of the process to an external syslog server. I am trying to use the CustomJavaComponent in combination with the log4j2 java library to accomplish this.
As I am quite new to Java, I have some trouble with how to set this up.
The syslog server is set up by our operations department and works well from other applications.
Thus far, I tried to test my setup with the following code within the execute function of the CustomJavaComponent:
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import java.io.*;
public class SyslogLogger extends AbstractGenericTransform
{
private static final Logger LOG = LogManager.getLogger(SyslogLogger.class);
public static void execute()
{
LOG.info("testing INFO level");
}
}
I have placed the configuration file (log4j2.xml) in the ${PROJECT}/trans folder.
My xml file looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<!-- Console appender -->
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %c %x - %enc{%m}{CRLF}%n"/>
</Console>
<Socket name="SYSLOGD" host="<myhostname>" port="514" protocol="UDP">
<PatternLayout
pattern="<1>%d{MMM dd HH:mm:ss} ${hostName} appName: {
"host":"${hostName}",
"thread":"%t",
"level":"%p",
"logger":"%c{1}",
"line":%L,
"message":"%enc{%m}",
"exception":"%exception"
}%n"
/>
</Socket>
</Appenders>
<Loggers>
<!-- Root logger -->
<Root level="INFO" additivity="false">
<AppenderRef ref="Console"/>
<AppenderRef ref="SYSLOGD"/>
</Root>
</Loggers>
</Configuration>
However, it seems like the CustomJavaComponent is not using the xml file I created as configuration, as we are not receiving the log messages on the server or in the console.
My questions are:
- Where do I place the xml file so that it will be used as configuration for the logging? Is it possible to only log the custom messages we’ve created to the external syslog server, while keeping the logs CloverDX creates during a process in the Console / Cloverlogs?
- (Or) is there an other way to log to an external syslog server more easily via CloverDX components, instead of a CustomJavaComponent with log4j?
Many thanks in advance,
Morris