登录Joomla平台11 JLog [英] Logging in Joomla platform 11 JLog

查看:101
本文介绍了登录Joomla平台11 JLog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用在Joomla平台11上构建的新Joomla 1.7系统-并且我从早期版本的Joomla中获取的所有日志记录代码都不再起作用(它们似乎正在编写日志条目,但语法不正确,因此消息为空白).

I'm playing with the new Joomla 1.7 system built on the Joomla platform 11-- and all my logging code from earlier versions of Joomla no longer work (they appear to be writing log entries but with improper syntax, so the messages are blank).

有人知道新版JLog的正确语法吗?这是我现有的代码-

Does anyone know the proper syntax for the new version of JLog? Here's my existing code--

$log = &JLog::getInstance('test.log.php');
$log->addEntry(array('COMMENT' => 'A test Logging message'));

这将创建日志文件,但实际的日志条目如下所示:

This creates the log file, but the actual log entry looks like this:

#<?php die('Forbidden.'); ?>
#Date: 2011-08-08 16:59:42 UTC
#Software: Joomla Platform 11.1 Stable+Modified [ Ember ] 01-Jun-2011 06:00 GMT

#Fields: date   time    priority    clientip    category    message
2011-08-08  16:59:42    INFO    127.0.0.1   -

我搜索了Joomla文档和网络,没有找到有关如何使用此类的示例.

I've searched the Joomla docs and the web and found no examples of how to use this class.

谢谢!

推荐答案

是的,Joomla 1.7中的日志记录确实发生了一些变化:

Yes, the logging changed a bit indeed in Joomla 1.7:

// Include the JLog class.
jimport('joomla.log.log');

// Add the logger.
JLog::addLogger(
     // Pass an array of configuration options
    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');

这篇关于登录Joomla平台11 JLog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆