Teradata Viewpoint uses a highly configurable logging mechanism to output log messages. By default, it has been configured to output log messages to the server console. You can use the logging mechanism described below to format and print log messages from your portlet. You may also choose to print the log messages to a file on disk, by enabling the 'File Appender' (described below) to log messages to a single log file, which is rotated by size.
Teradata Viewpoint components use commons-logging along with log4j to log messages. A basic understanding of log4j is assumed. A short introduction can be found here.
In order to enable log4j logging, you need to configure the appropriate logger for your portlet in the log4j.xml file.
Note: Although it is possible to have your own copy of the log4j configuration file, we recommend adding your entries to the shared log4j.xml in $VIEWPOINT_HOME/common.
For example, if your portlet is in a package com.teradata.portlets.hello, then add the following entry to the log4j.xml file:
<level value="DEBUG" />
This configures a logger for your portlet that logs all messages of severity DEBUG and greater. Valid values for level are: TRACE, DEBUG, INFO, WARN, ERROR, and FATAL. refer to log4j documentation for more information on logger hierarchies and log-level inheritance.
During development, you should set the level at DEBUG. In production, we recommend using WARN or greater.
Changes to the log4j.xml are picked up the next time the Teradata Viewpoint Server is restarted. At this point, you should see your log messages being written to viewpoint.log (see next section on how to use loggers in your code).
Always declare logs as static members using commons-logging. This ensures that your code is decoupled from any logging implementation specifics:
private static final Log logger = LogFactory.getLogger(MySuperDooperClass.class);
private void someMethod()
catch (SomeException se)
logger.warn("An error occurred while doing something", se)
At this point, your portlet log messages are being written to the server console. You may choose to print log messages to a file instead. Viewpoint provides a default log file, located at $VIEWPOINT_HOME/logs/viewpoint.log. In order to output log messages to file, add the following entry to the log4j.xml file:
<level value="INFO" />
<appender-ref ref="FILE" />
<appender-ref ref="CONSOLE" />
Upon restarting the Teradata Viewpoint Server, all log messages will be written to $VIEWPOINT_HOME/logs/viewpoint.log. The file will be rotated when it reaches 100 MB, and the server will retain the last 10 files on disk.
By default, Viewpoint logs messages at log level INFO and higher to the server console. You may change these modifying the following values in viewpoint.properties before building your portal.
# Logging settings