JBoss.orgCommunity Documentation
The Teiid system provides a wealth of information using logging. To control logging level,
contexts, and log locations, you should be familiar with log4j and the container's
jboss-log4j.xml
configuration file. Teiid also provides a
containing
much of information from this chapter. Refer to the Administrator Guide for more details about
different Teiid contexts available. Refer to http://logging.apache.org/log4j/
for more information about log4j.
PROFILE
/conf/jboss-teiid-log4j.xml
If the default log4j logging mechanisms are not sufficient for your logging needs you may need a different appender, refer to the log4j javadocs at http://logging.apache.org/log4j/1.2/apidocs/index.html. Note that log4j already provides quite a few appenders including JMS, RDBMS, and SMTP.
If you want a custom appender, follow the Log4J directions to write a custom appender. Refer to the instructions at http://logging.apache.org/log4net/release/faq.html. If you develop a custom logging solution, the implementation jar should be placed in the "lib" directory of the JBoss AS server profile Teiid is installed in.
If you want to build a custom appender for command logging that will have access to
log4j "LoggingEvents" to the "COMMAND_LOG" context, the appender will receive a message that is an instance of
org.teiid.logging.CommandLogMessage
. The relevant Teiid classes are defined in the teiid-api-7.6.jar
.
The CommmdLogMessage includes information about vdb, session, command sql, etc. CommandLogMessages are logged at the DEBUG level.
Example 7.1. Sample CommandLogMessage Usage
package org.something;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;
import org.teiid.logging.*;
public class CustomAppender extends AppenderSkeleton
{
protected void append(LoggingEvent event) {
if (event.getMessage() instanceof CommandLogMessage) {
CommandLogMessage clMessage = (CommandLogMessage)event.getMessage();
String sql = clMessage.getSql();
...
//log to a database, trigger an email, etc.
}
...
}
...
}
If you want to build a custom appender for command logging that will have access to
log4j "LoggingEvents" to the "org.teiid.AUDIT_LOG" context, the appender will receive a message that is an instance of
org.teiid.logging.AuditMessage
. The relevant Teiid classes are defined in the teiid-api-7.6.jar
. The AuditMessage
includes information about user, the action, and the
target(s) of the action. AuditMessages are logged at the DEBUG level.
Example 7.2. Sample AuditMessage Usage
package org.something;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;
import org.teiid.logging.*;
public class CustomAppender extends AppenderSkeleton
{
protected void append(LoggingEvent event) {
if (event.getMessage() instanceof AuditMessage) {
AuditMessage auditMessage = (AuditMessage)event.getMessage();
String activity = auditMessage.getActivity();
...
//log to a database, trigger an email, etc.
}
...
}
...
}