为了创建Magento日志,可以写一些类似的东西
Mage::log('Server Side Validation kicked in for Year for '.$currentYearType);
Run Code Online (Sandbox Code Playgroud)
但是,如果我要在一个单独的文件中添加日志,那么我
Mage::log('Server Side Validation kicked in for Year for ' ,null,'serversidevalidation.log');
Run Code Online (Sandbox Code Playgroud)
如果我错了,请纠正我.
如果是这样,中间使用null有什么用?此外,文件是否需要事先存在,或者我认为它是在需要时由系统创建的.我对吗?此外,它还包括时间戳吗?
Mee*_*m R 16
转到 app/Mage.php
785行
public static function log($message, $level = null, $file = '', $forceLog = false)
Run Code Online (Sandbox Code Playgroud)
你可以看到第二个参数是水平的
$level = is_null($level) ? Zend_Log::DEBUG : $level;
Run Code Online (Sandbox Code Playgroud)
LIB\Zend的\ log.php
const EMERG = 0; // Emergency: system is unusable
const ALERT = 1; // Alert: action must be taken immediately
const CRIT = 2; // Critical: critical conditions
const ERR = 3; // Error: error conditions
const WARN = 4; // Warning: warning conditions
const NOTICE = 5; // Notice: normal but significant condition
const INFO = 6; // Informational: informational messages
const DEBUG = 7; // Debug: debug messages
Run Code Online (Sandbox Code Playgroud)
如果你这个代码 Mage::log('test', 1);
然后你得到这样的日志文件输出
2014-05-17T12:21:51+00:00 ALERT (1): test
Run Code Online (Sandbox Code Playgroud)
是的,该文件在调用时由系统自动创建
system包括调用时的时间戳
请参阅app/Mage.php第825行中的此代码
$format = '%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL;
$formatter = new Zend_Log_Formatter_Simple($format);
Run Code Online (Sandbox Code Playgroud)
干杯
| 归档时间: |
|
| 查看次数: |
9102 次 |
| 最近记录: |