powered by Namazu on
metasearch.sourceforge.jp
CommonsLogging
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
[[PHPベストプラクティス]] >
* PHP CommonsLogging (0.9.0以降) [#j9df52ee]
-PHP CommonsLogging を利用した透過的なログ出力により、ロ...
#contents
** 使用例 [#s9685737]
-クラスでは、通常ロガーは''静的メンバ''に格納しますので、...
-クラス内での後処理(shutdown)は、デストラクタメソッド内...
#code(php){{
<?php
require_once 'Commons/Logging/LogFactory.php';
// ...
$log = Commons_Logging_LogFactory::getLog(
Commons_Logging_LogUtils::normalize(__CLASS__));
if ($log->isDebugEnabled()) {
$log->debug('debug message.');
}
$log->warn('warn message.');
// ...
$log->shutdown();
?>
}}
** 設定 [#q3e9d841]
*** 明示的設定の優先順位 [#l690538d]
-デフォルトのログファクトリ実装(Commons_Logging_Impl_Log...
|~順位|~設定場所|~備考|
|1|設定ファイル(commons-logging.properties)||
|2|環境変数(getenvで取得)||
*** 設定ファイル [#lbf8523d]
-include_path のルートにある ''commons-logging.properties...
*** 設定プロパティ [#e2553471]
-設定ファイルでは、以下のプロパティを設定できます。もちろ...
|~No.|~プロパティ|~説明|~デフォルト|~備考|
|1|commons.logging.LogFactory|ログファクトリ実装クラス名|...
|2|commons.logging.Log|ロガー実装クラス名|-||
|3|log4php.configuration|log4php設定ファイルパス(include...
|4|pearlog.configuration|PEAR Log設定ファイルパス(includ...
-設定例
#code(bash){{
## Default LogFactory
#commons.logging.LogFactory = Commons_Logging_Impl_LogFac...
## Default Logger
#commons.logging.Log = Commons_Logging_Impl_SimpleLog
## No operation logger
#commons.logging.Log = Commons_Logging_Impl_NoOpLog
## PEAR Log logger
#commons.logging.Log = Commons_Logging_Impl_PEARLogLogger
commons.logging.Log = Commons_Logging_Impl_Log4PHPLogger
## Log4PHP Property (optional)
## LOG4PHP_CONFIGURATION
log4php.configuration = /etc/log4php/log4php.properties
## PEAR Log Property (required)
#pearlog.configuration = Commons/Logging/Impl/pearlog.pro...
}}
*** デフォルト設定 [#n77ba62e]
-何も設定を行わない場合、以下の順に利用可能なロギングフレ...
|~順位|~ロギングフレームワーク|~備考|
|1|log4php||
|2|[[PEAR Log>http://pear.php.net/package/Log]]||
|3|SimpleLog|PHP Commons組込み|
*** NDC、MDC(ver. 1.0.3以降) [#t10ec335]
-診断コンテキスト(diagnostic context)は、主に同一リクエス...
-NDC(Nested Diagnostic Contexts): スタックモデルで、診断...
|~No.|~インタフェイス|~説明|~備考|
|1|Log#pushNDC|診断コンテキストとして、メッセージをスタッ...
|2|Log#popNDC|プッシュされた最後のメッセージをスタックか...
|3|Log#clearNDC|診断コンテキストスタックをすべてクリアし...
-NDC(Mapped Diagnostic Contexts): マップに診断コンテキス...
|~No.|~インタフェイス|~説明|~備考|
|1|Log#putMDC|診断コンテキストとして、メッセージをマップ...
|2|Log#removeMDC|メッセージをマップから削除します。||
*** Log4PHP 設定 [#bcbe225a]
-commons-logging.properites 内の ''log4php.configuration'...
-log4phpは、設定ファイルの拡張子によって、フォーマット(...
-なお、log4php では、LoggerManager.phpロード時((CommonsLo...
*** PEAR Log 設定 [#g9970951]
-PEAR Log 自身には、設定ファイルに基づいてロガーを構築す...
-PEAR Log には、カテゴリの概念と継承機能がありませんが、P...
-また、PEAR Log にある、任意のプライオリティレベルのマス...
-設定ファイルによる設定を行わない場合には、標準エラーにIN...
-設定フォーマットは以下の通りです。ロガーとログハンドラ((...
|~No.|~プロパティ|~説明|~必須|~設定例|~備考|
|1|pearlog.rootLogger|ルートロガーの設定|○|"INFO, C1, F1"...
|2|pearlog.logger.<カテゴリ名>|ロガーの設定|-|"DEBUG, C1,...
|3|pearlog.additivity.<カテゴリ名>|ハンドラのAdditivity(...
|4|pearlog.handler.<ハンドラ識別子>|ログハンドラのタイプ...
|5|pearlog.handler.<ハンドラ識別子>.resource|ログハンドラ...
|6|pearlog.handler.<ハンドラ識別子>.<ハンドラ設定パラメー...
-設定ファイル例
#code(bash){{
pearlog.rootLogger=INFO, C1, F1
pearlog.logger.Commons.Logging=DEBUG, SYS1
pearlog.additivity.Commons.Logging=true
pearlog.logger.Commons.Logging.Impl=INHERIT, F1
pearlog.additivity.Commons.Logging=false
pearlog.handler.C1=console
pearlog.handler.C1.resource=
pearlog.handler.C1.stream=STDOUT
pearlog.handler.C1.buffering=false
pearlog.handler.C1.lineFormat=%1$s %2$s [%3$s] %4$s
pearlog.handler.C1.timeFormat=%b %d %H:%M:%S
pearlog.handler.F1=file
pearlog.handler.F1.resource=/tmp/commons.log
pearlog.handler.F1.append=true
pearlog.handler.F1.locking=false
pearlog.handler.F1.mode=0644
pearlog.handler.F1.dirmode=0755
pearlog.handler.F1.eol=\n
pearlog.handler.F1.lineFormat=%1$s %2$s [%3$s] %4$s
pearlog.handler.F1.timeFormat=%b %d %H:%M:%S
pearlog.handler.SYS1=syslog
pearlog.handler.SYS1.resource=LOG_SYSLOG
pearlog.handler.SYS1.inherit=false
}}
*** SimpleLog 設定 [#rc96f020]
-何も設定しない場合には、標準エラーに、INFOレベル以上のロ...
-設定は、環境変数、設定ファイルの順に優先されます。
-設定ファイルを利用する場合には、''include_path のルート...
-設定例は以下の通り。プロパティ名は、環境変数で設定する場...
#code(bash){{
# Priority Levels: ALL, TRACE, DEBUG, INFO, WARN, ERROR, ...
# Default settings
#commons.logging.simplelog.showlogname = false
#commons.logging.simplelog.showShortLogname = true
#commons.logging.simplelog.showdatetime = false
#commons.logging.simplelog.defaultlog = INFO
commons.logging.simplelog.log.Commons.Logging = DEBUG
}}
** 参考 [#s93006ba]
-[[Apache Commons Logging>http://commons.apache.org/loggi...
終了行:
[[PHPベストプラクティス]] >
* PHP CommonsLogging (0.9.0以降) [#j9df52ee]
-PHP CommonsLogging を利用した透過的なログ出力により、ロ...
#contents
** 使用例 [#s9685737]
-クラスでは、通常ロガーは''静的メンバ''に格納しますので、...
-クラス内での後処理(shutdown)は、デストラクタメソッド内...
#code(php){{
<?php
require_once 'Commons/Logging/LogFactory.php';
// ...
$log = Commons_Logging_LogFactory::getLog(
Commons_Logging_LogUtils::normalize(__CLASS__));
if ($log->isDebugEnabled()) {
$log->debug('debug message.');
}
$log->warn('warn message.');
// ...
$log->shutdown();
?>
}}
** 設定 [#q3e9d841]
*** 明示的設定の優先順位 [#l690538d]
-デフォルトのログファクトリ実装(Commons_Logging_Impl_Log...
|~順位|~設定場所|~備考|
|1|設定ファイル(commons-logging.properties)||
|2|環境変数(getenvで取得)||
*** 設定ファイル [#lbf8523d]
-include_path のルートにある ''commons-logging.properties...
*** 設定プロパティ [#e2553471]
-設定ファイルでは、以下のプロパティを設定できます。もちろ...
|~No.|~プロパティ|~説明|~デフォルト|~備考|
|1|commons.logging.LogFactory|ログファクトリ実装クラス名|...
|2|commons.logging.Log|ロガー実装クラス名|-||
|3|log4php.configuration|log4php設定ファイルパス(include...
|4|pearlog.configuration|PEAR Log設定ファイルパス(includ...
-設定例
#code(bash){{
## Default LogFactory
#commons.logging.LogFactory = Commons_Logging_Impl_LogFac...
## Default Logger
#commons.logging.Log = Commons_Logging_Impl_SimpleLog
## No operation logger
#commons.logging.Log = Commons_Logging_Impl_NoOpLog
## PEAR Log logger
#commons.logging.Log = Commons_Logging_Impl_PEARLogLogger
commons.logging.Log = Commons_Logging_Impl_Log4PHPLogger
## Log4PHP Property (optional)
## LOG4PHP_CONFIGURATION
log4php.configuration = /etc/log4php/log4php.properties
## PEAR Log Property (required)
#pearlog.configuration = Commons/Logging/Impl/pearlog.pro...
}}
*** デフォルト設定 [#n77ba62e]
-何も設定を行わない場合、以下の順に利用可能なロギングフレ...
|~順位|~ロギングフレームワーク|~備考|
|1|log4php||
|2|[[PEAR Log>http://pear.php.net/package/Log]]||
|3|SimpleLog|PHP Commons組込み|
*** NDC、MDC(ver. 1.0.3以降) [#t10ec335]
-診断コンテキスト(diagnostic context)は、主に同一リクエス...
-NDC(Nested Diagnostic Contexts): スタックモデルで、診断...
|~No.|~インタフェイス|~説明|~備考|
|1|Log#pushNDC|診断コンテキストとして、メッセージをスタッ...
|2|Log#popNDC|プッシュされた最後のメッセージをスタックか...
|3|Log#clearNDC|診断コンテキストスタックをすべてクリアし...
-NDC(Mapped Diagnostic Contexts): マップに診断コンテキス...
|~No.|~インタフェイス|~説明|~備考|
|1|Log#putMDC|診断コンテキストとして、メッセージをマップ...
|2|Log#removeMDC|メッセージをマップから削除します。||
*** Log4PHP 設定 [#bcbe225a]
-commons-logging.properites 内の ''log4php.configuration'...
-log4phpは、設定ファイルの拡張子によって、フォーマット(...
-なお、log4php では、LoggerManager.phpロード時((CommonsLo...
*** PEAR Log 設定 [#g9970951]
-PEAR Log 自身には、設定ファイルに基づいてロガーを構築す...
-PEAR Log には、カテゴリの概念と継承機能がありませんが、P...
-また、PEAR Log にある、任意のプライオリティレベルのマス...
-設定ファイルによる設定を行わない場合には、標準エラーにIN...
-設定フォーマットは以下の通りです。ロガーとログハンドラ((...
|~No.|~プロパティ|~説明|~必須|~設定例|~備考|
|1|pearlog.rootLogger|ルートロガーの設定|○|"INFO, C1, F1"...
|2|pearlog.logger.<カテゴリ名>|ロガーの設定|-|"DEBUG, C1,...
|3|pearlog.additivity.<カテゴリ名>|ハンドラのAdditivity(...
|4|pearlog.handler.<ハンドラ識別子>|ログハンドラのタイプ...
|5|pearlog.handler.<ハンドラ識別子>.resource|ログハンドラ...
|6|pearlog.handler.<ハンドラ識別子>.<ハンドラ設定パラメー...
-設定ファイル例
#code(bash){{
pearlog.rootLogger=INFO, C1, F1
pearlog.logger.Commons.Logging=DEBUG, SYS1
pearlog.additivity.Commons.Logging=true
pearlog.logger.Commons.Logging.Impl=INHERIT, F1
pearlog.additivity.Commons.Logging=false
pearlog.handler.C1=console
pearlog.handler.C1.resource=
pearlog.handler.C1.stream=STDOUT
pearlog.handler.C1.buffering=false
pearlog.handler.C1.lineFormat=%1$s %2$s [%3$s] %4$s
pearlog.handler.C1.timeFormat=%b %d %H:%M:%S
pearlog.handler.F1=file
pearlog.handler.F1.resource=/tmp/commons.log
pearlog.handler.F1.append=true
pearlog.handler.F1.locking=false
pearlog.handler.F1.mode=0644
pearlog.handler.F1.dirmode=0755
pearlog.handler.F1.eol=\n
pearlog.handler.F1.lineFormat=%1$s %2$s [%3$s] %4$s
pearlog.handler.F1.timeFormat=%b %d %H:%M:%S
pearlog.handler.SYS1=syslog
pearlog.handler.SYS1.resource=LOG_SYSLOG
pearlog.handler.SYS1.inherit=false
}}
*** SimpleLog 設定 [#rc96f020]
-何も設定しない場合には、標準エラーに、INFOレベル以上のロ...
-設定は、環境変数、設定ファイルの順に優先されます。
-設定ファイルを利用する場合には、''include_path のルート...
-設定例は以下の通り。プロパティ名は、環境変数で設定する場...
#code(bash){{
# Priority Levels: ALL, TRACE, DEBUG, INFO, WARN, ERROR, ...
# Default settings
#commons.logging.simplelog.showlogname = false
#commons.logging.simplelog.showShortLogname = true
#commons.logging.simplelog.showdatetime = false
#commons.logging.simplelog.defaultlog = INFO
commons.logging.simplelog.log.Commons.Logging = DEBUG
}}
** 参考 [#s93006ba]
-[[Apache Commons Logging>http://commons.apache.org/loggi...
ページ名: