Logging
CADP for Java allows the user to generate and maintain system logs either on local machine or on SysLog Server. To save logs, it is required to configure the logging properties. The CADP for Java allows you to configure the logging libraries using either the standard log4j2.xml file or CADP_for_JAVA.properties file. properties.
These files are two means of configuring the same logging library, which is based on log4j2. The underlying functionality is the same, although more features are exposed through the log4j2.xml file. Different properties in CADP_for_JAVA.properties
file are configured for local and SysLog server logging.
If both local logging and syslog logging are set, logs will be captured in only one server with first priority set for SysLog Server. If SysLog Server is not available, then local logging will happen.
The detailed instructions to configure log4j2.xml file is mentioned in https://logging.apache.org/log4j/2.x/manual/.
Using the log4j2.xml file
The log4j2.xml file uses full suite of logging features supported by log4j2. This section describes how to implement some of the more common features. The following samples shows the behavior of the basic logging parameters in the CADP_for_JAVA.properties file. Place the log4j2.xml file in a directory declared in the class path.
Sample for CADP_for_JAVA.properties
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
Sample for Syslog Server
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="OFF" name="MyApp">
<Appenders>
<Socket name="socket" host="<IP address of the SysLog server>" port="<port number of the SysLog server" protocol="SSL"
ignoreExceptions="false">
<Ssl>
<KeyStore location="<location of the KeyStore>"
password="<password associated with the KeyStore>" type="JKS" />
<TrustStore location="<location of the TrustStore>"
password="<password associated with the TrustStore>" type="JKS" />
</Ssl>
</Socket>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="socket" />
</Root>
</Loggers>
</Configuration>
Here,
Logger element The logger element controls which messages are logged.
Appender determines whether those messages are filtered, sent to a log file, and if that log file is rotated.
Encoder indicates how each log message is recorded in the log file.
The following table shows possible level attribute settings and the corresponding logging levels:
Level Attribute Settings | Logging Level |
---|---|
ERROR | Error messages regarding the client connection to the Key Manager are logged. |
WARN | Errors and warnings regarding the client connection to the Key Manager are logged. |
INFO | Errors, warnings, and information messages are logged. This creates large log files. |
DEBUG | Errors, warnings, information and debugging messages are logged. |
Using the properties file
The CADP_for_JAVA.properties file exposes the following parameters that are a subset of the features that are available in a well configured log4j2.xml file.
log levels
log file naming
log rotation
timestamps
log size limit
System Log IP
System Log Port
System Log Protocol
Parameters for logging on SysLog server
SysLog IP
SysLog Port
SysLog Protocol
SysLog SSL KeyStore
SysLog SSL KeyStore Password
The details of these parameters are available in Logging Parameters.
Parameters for local logging
Log Levels
Log File Naming
Log Rotation
Log Size Limit
GMT Timestamp Offset
The details of these parameters are available in Logging Parameters.
To know about the supported logging tasks, refer to Logging Related Tasks.