5.2. Log setup of S2Container

In S2Container, Logger instance is acquired by the s2logger method as follows, and a log output is performed.

require 's2container'
s2logger.debug(File::basename(__FILE__)) { "debug test." }

5.2.1. S2Logger

In S2Container, Logger instance which performs a log output is acquired through Seasar::Log::S2Logger class. S2Logger.logger method returns the instance of Logger which performs STDERR output. As a shortcut, the s2logger method returns Seasar::Log::S2Logger class.

Setting a log device. 

When specifying the output place of a log, it specifies by the argument of the s2logger method.

require 's2container'
s2logger(STDOUT).debug(File::basename(__FILE__)) { "debug test." }

Setting a log level. 

A level setup of a log output is performed to Logger instance taken out from S2Logger.

require 's2container'
s2logger.level = Logger::WARN
s2logger.debug(File::basename(__FILE__)) { "debug test." }
s2logger.info(File::basename(__FILE__)) { "info test." }
s2logger.warn(File::basename(__FILE__)) { "warn test." }
s2logger.error(File::basename(__FILE__)) { "error test." }
s2logger.fatal(File::basename(__FILE__)) { "fatal test." }


© Copyright The Seasar Foundation and the others 2008-2009, all rights reserved.