【问题标题】:Jlog Getinstance in Joomla 3.0?Joomla 3.0 中的 Jlog Getinstance?
【发布时间】:2013-01-13 14:13:12
【问题描述】:

我为 Joomla 2.5 做了一个小扩展,它成功了。 但问题是当我试图使其与 Joomla 3 兼容时,我收到有关 JLog::getInstance 方法未找到的错误。 我知道他们删除了它并被 JLogLogger 取代,但这也不起作用。

有人可以帮助我并使其工作吗? 我在 Joomla 2.5 中使用的代码是

$log = JLog::getInstance();
$log->addEntry(array('comment' => $server['REMOTE_ADDR'] . " is allowed"));

我创建了一个名为 $log 的变量,因为我更多地使用它。 这只是扩展中的一小段代码。

【问题讨论】:

标签: php joomla joomla-extensions


【解决方案1】:

此代码来自similar question

jimport('joomla.log.log');

JLog::addLogger(
    array(
            // Set the name of the log file
            'text_file' => 'test.log.php',
            // (optional) you can change the directory
            'text_file_path' => 'somewhere/logs'
     )
);

// start logging...
JLog::add('Starting to log'); 

如果上面的代码不起作用,请尝试将jimport('joomla.log.log'); 添加到它自己的文件顶部。

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2011-11-27
    • 1970-01-01
    • 2013-09-24
    • 2013-05-10
    • 2013-02-23
    • 2012-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多