compared with
Current by Bart Kamphorst
on Apr 06, 2009 14:24.


 
Key
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history


There are 3 changes. View first change.

 h3. Introduction
  
 Colored Trails uses [Apache log4J|http://logging.apache.org/log4j/1.2/index.html|Apache log4J website] as a default logging mechanism. A short log4J manual can be found [here|http://logging.apache.org/log4j/1.2/manual.html|Apache log4J manual].
  
 In the Colored Trails code the log4J configuration file is located in
 {code:borderStyle=solid}lib/conf/log4j.properties
 {code}
 h3. Logging to stdout (standard output)
  
 In Colored Trails Log4J is configured to log all log statements (debug and lower) to stdout.
  
 h3. An example
  
Every Java class in the CT code can use the log4J mechanism. An example:
 {code: Title=Log4J example}import org.apache.log4j.Logger;
  
 Logger logger = Logger.getLogger(this.getClass().getName());
  
 logger.debug("Example log statement");
 {code}
  
 h3. Logging to MySQL
  
  *Please note that the following instructions only concern the Colored Trails trunk*
  
 You may want to log your server output to a database. Log4J supports a JDBC Appender to log to a MySQL database. You can activate the JDBC Appender for the Colored Trails project by simply some uncommenting a few lines in the log4j.properties file.
  
 In order to create a database and a table for the JDBC Appender to log to, use the SQL commands below.
  
 {code:sql Title=CreateDB.sql}CREATE DATABASE IF NOT EXISTS db_name
 where db_name is the name of the database you would like to create.
 {code}
 {code:sql}CREATE TABLE `table_name` (
  `Id` int(11) NOT NULL auto_increment,
  `Logger` varchar(64) default NULL,
  `Priority` varchar(10) default NULL,
  `Message` varchar(250) default NULL,
  `Date` varchar(40) default NULL,
  PRIMARY KEY (`Id`)
 ) ENGINE=MyISAM AUTO_INCREMENT=1005 DEFAULT CHARSET=utf8
 {code}
 h3. An example
  
 Every Java class in the CT code can use the log4J mechanism. An example:
 {code: Title=Log4J example}import org.apache.log4j.Logger;
  
 Logger logger = Logger.getLogger(this.getClass().getName());
  
 logger.debug("Example log statement");
 {code}