Enabling logging in an extension

You can enable logging in an extension to provide diagnostic information about the extension as it runs in an acquisition. An extension writes to the <install path>\CAS\workspace\logs\cas-service.log file using one of the common logging frameworks.

Supported logging frameworks

The Content Acquisition System supports the following logging frameworks:
  • SLF4J
  • Apache Commons Logging
  • java.util.logging
  • Log4J

Oracle recommends the SLF4J framework because its parameterized logging minimizes the performance impact of disabled logging statements. For details, see the SLF4J documentation at http://www.slf4j.org.

Integrating logging

Integration is largely transparent. You import the logging framework into the PipelineComponentRuntime and call getLogger(). If any logging requests come in from any of the frameworks, the Content Acquisition System detects the requests and redirects them to Log4J which CAS then uses to write to cas-service.log.

For example, if you are using SLF4J, integration is similar to the following:
import org.slf4j.LoggerFactory
...

LoggerFactory.getLogger(getClass()).info("A logging message.");

Changing log levels

You can change log levels by modifying log4j.logger.loggerName properties in <install path>\CAS\workspace\conf\cas-service-log4j.properties. The default log level is set to WARN.

For example, this Log4J entry sets the log level to DEBUG for the sample substring manipulator.
log4j.logger.com.endeca.cas.extension.sample.manipulator.substring.SubstringManipulatorRuntime=DEBUG

After you modify, save, and close the cas-service-log4j.properties file, you must restart the Endeca CAS Service for the change to take effect.

The Log level setting in the data source's configuration

Data sources include several advanced configuration properties by default: you do not need to implement these properties as Java fields in an PipelineComponentConfiguration class. An application developer can set these properties using the CAS Server Command-line Utility, the CAS Server API, and in the CAS Console (on the Advanced Settings tab). The log level setting applies to high-level aspects of a data acquisition, such as logging crawl history, but the log level setting does not apply to the data source extension itself.