The Teiid system provides a wealth of information using logging. To control logging level, contexts, and log locations, you should be familiar with container's {{standalone.xml}} or {{domain.xml}} configuration fileand check out "logging" subsystem. 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. |
The Teiid system provides a wealth of information using logging. To control logging level, contexts, and log locations, you should be familiar with container's {{standalone.xml}} or {{domain.xml}} configuration file and check out "logging" subsystem. Refer to the [Administrator's Guide] for more details about different [Teiid contexts|Logging] available. |
|
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 as a jar in "org.jboss.teiid" module and define its name in the module.xml file as part of the module. |
If you want a custom log handler, follow the directions to write a custom _[java.util.logging.Handler|http://docs.oracle.com/javase/6/docs/api/java/util/logging/Handler.html]_. If you develop a custom logging Handler, the implementation class along should be placed as a jar in "org.jboss.teiid" module and define its name in the module.xml file as part of the module along with any dependencies it may need. See below. |
h1. Command Logging API |
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. |
If you want to build a custom handler for command logging that will have access to java.util.logging [LogRecords|http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html] to the "COMMAND\_LOG" context, the handler will receive a instance of LogRecord message, this object will contain a parameter of type {{org.teiid.logging.CommandLogMessage}}. The relevant Teiid classes are defined in the _teiid\-api\-{space-metadata-from:fullVersionNumber}.jar_. The CommmdLogMessage includes information about vdb, session, command sql, etc. CommandLogMessages are logged at the DEBUG level. |
|
{code:lang=Java|title=Sample CommandLogMessage Usage}package org.something; |
package org.something; |
import org.apache.log4j.AppenderSkeleton; java.util.logging.Handler; |
import org.apache.log4j.spi.LoggingEvent; java.util.logging.LogRecord; |
import org.teiid.logging.*; |
|
public class CustomAppender extends AppenderSkeleton |
public class CommandHandler extends Handler { |
{ @Override |
protected void append(LoggingEvent event) { if (event.getMessage() instanceof CommandLogMessage) { CommandLogMessage clMessage = (CommandLogMessage)event.getMessage(); String sql = clMessage.getSql(); ... |
public void publish(LogRecord record) { CommandLogMessage msg = (CommandLogMessage)record.getParameters()[0]; |
//log to a database, trigger an email, etc. |
} |
... } ... }{code} |
|
@Override public void flush() { } @Override public void close() throws SecurityException { } } {code} |
h1. Audit Logging API 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. |
{code:lang=Java|title=Sample AuditMessage Usage}package org.something; import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.spi.LoggingEvent; import org.teiid.logging.*; |
If you want to build a custom handler for command logging that will have access to java.util.logging [LogRecords|http://docs.oracle.com/javase/6/docs/api/java/util/logging/LogRecord.html] to the "AUDIT\_LOG" context, the handler will receive a instance of LogRecord message, this object will contain a parameter of type {{org.teiid.logging.AuditMessage}}. The relevant Teiid classes are defined in the _teiid\-api\-{space-metadata-from:fullVersionNumber}.jar_. AuditMessages are logged at the DEBUG level. |
|
public class CustomAppender extends AppenderSkeleton |
{code:lang=Java|title=Sample AuditMessage Usage} package org.something; import java.util.logging.Handler; import java.util.logging.LogRecord; |
{ |
public class AuditHandler extends Handler { |
@Override |
protected void append(LoggingEvent event) { if (event.getMessage() instanceof AuditMessage) { AuditMessage auditMessage = (AuditMessage)event.getMessage(); String activity = auditMessage.getActivity(); ... |
public void publish(LogRecord record) { AuditMessage msg = (AuditMessage)record.getParameters()[0]; |
//log to a database, trigger an email, etc. |
} |
... |
} @Override |
public void flush() { |
} |
... |
@Override |
public void close() throws SecurityException { |
}{code} } |
} {code} h1. Configuration Now that you have developed a custom handler class, now package implementation in Jar file, then copy this Jar file into {{<jboss\-as7>/modules/org/jboss/teiid/main}} folder, and edit {{module.xml}} file in the same directory and add {code} <resource-root path="{your-jar-name}.jar" /> {code} then edit {{standalone-teiid.xml}} or {{domain.xml}} file, locate the "logging" subsystem and add the following entries. {code} <custom-handler name="COMMAND" class="org.teiid.logging.CommandHandler" module="org.jboss.teiid"> </custom-handler> ..other entries <logger category="org.teiid.COMMAND_LOG"> <level name="DEBUG"/> <handlers> <handler name="COMMAND"/> </handlers> </logger> {code} Change the above configuration accordingly for AuditHandler, if you are working with Audit Messages. |
The Teiid system provides a wealth of information using logging. To control logging level, contexts, and log locations, you should be familiar with container's standalone.xml or domain.xml configuration file and check out "logging" subsystem. Refer to the Administrator's Guide for more details about different Teiid contexts available.
If you want a custom log handler, follow the directions to write a custom java.util.logging.Handler. If you develop a custom logging Handler, the implementation class along should be placed as a jar in "org.jboss.teiid" module and define its name in the module.xml file as part of the module along with any dependencies it may need. See below.
If you want to build a custom handler for command logging that will have access to java.util.logging LogRecords to the "COMMAND_LOG" context, the handler will receive a instance of LogRecord message, this object will contain a parameter of type org.teiid.logging.CommandLogMessage. The relevant Teiid classes are defined in the teiid-api-8.2.0.Final.jar. The CommmdLogMessage includes information about vdb, session, command sql, etc. CommandLogMessages are logged at the DEBUG level.
package org.something; import java.util.logging.Handler; import java.util.logging.LogRecord; public class CommandHandler extends Handler { @Override public void publish(LogRecord record) { CommandLogMessage msg = (CommandLogMessage)record.getParameters()[0]; //log to a database, trigger an email, etc. } @Override public void flush() { } @Override public void close() throws SecurityException { } }
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.
If you want to build a custom handler for command logging that will have access to java.util.logging LogRecords to the "AUDIT_LOG" context, the handler will receive a instance of LogRecord message, this object will contain a parameter of type org.teiid.logging.AuditMessage. The relevant Teiid classes are defined in the teiid-api-8.2.0.Final.jar. AuditMessages are logged at the DEBUG level.
package org.something; import java.util.logging.Handler; import java.util.logging.LogRecord; public class AuditHandler extends Handler { @Override public void publish(LogRecord record) { AuditMessage msg = (AuditMessage)record.getParameters()[0]; //log to a database, trigger an email, etc. } @Override public void flush() { } @Override public void close() throws SecurityException { } }
Now that you have developed a custom handler class, now package implementation in Jar file, then copy this Jar file into <jboss-as7>/modules/org/jboss/teiid/main folder, and edit module.xml file in the same directory and add
<resource-root path="{your-jar-name}.jar" />
then edit standalone-teiid.xml or domain.xml file, locate the "logging" subsystem and add the following entries.
<custom-handler name="COMMAND" class="org.teiid.logging.CommandHandler" module="org.jboss.teiid"> </custom-handler> ..other entries <logger category="org.teiid.COMMAND_LOG"> <level name="DEBUG"/> <handlers> <handler name="COMMAND"/> </handlers> </logger>
Change the above configuration accordingly for AuditHandler, if you are working with Audit Messages.