Dashboard > Penrose 1.0 > ... > Embedding Penrose > Logging Configuration
Logging Configuration
Added by Endi S. Dewata, last edited by Endi S. Dewata on Feb 28, 2006
Labels: 
(None)


Introduction

When you run Penrose as a stand-alone server, it configures Log4j based on the command line parameters or the log4j.properties. See Logging.

When you run Penrose in an embedded environment, Penrose does not configure Log4j. It's your responsibility to configure the loggers and appenders either using Log4j API or using a configuration file. Please refer to Log4j documentation.

Log4j API

Here is an example how to setup logging using Log4j API.

Layout layout = new PatternLayout("[%d{MM/dd/yyyy HH:mm:ss}] %m%n");
ConsoleAppender appender = new ConsoleAppender(layout);
BasicConfigurator.configure(appender);

Logger rootLogger = Logger.getRootLogger();
rootLogger.setLevel(Level.OFF);

Logger logger = Logger.getLogger("org.safehaus.penrose");
logger.setLevel(Level.DEBUG);

Configuration File

Here is an example of log4j.properties:

log4j.debug=false
log4j.rootLogger=OFF

log4j.logger.org.safehaus.penrose=DEBUG, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{MM/dd/yyyy HH:mm:ss}] %m%n

You can load the configuration using the following code:

String filename = "log4j.properties";
PropertyConfigurator.configure(filename);

References

Site running on a free Atlassian Confluence Open Source Project License granted to Safehaus. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators