[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TYPO3-dev] Status of "devlog" extension



Hi.

On 06.06.2013 11:24 Xavier Perseguers wrote:
> 
> See for idea: http://logging.apache.org/log4j/1.2/
> 

log4j acted as one of the models for the TYPO3 Logging API :)

> In my code I'd like to write code such as
> 
> Logger.log('whatever', TYPE::DEBUG);
> Logger.log('whatever', TYPE::INFO);
> Logger.log('whatever', TYPE::WARNING);
> 
> and then (by default) throw = not log all TYPE::DEBUG messages and be
> able to configure debug messages to go to another table/file/... if
> needed, most probably together with other levels as well:
> 
>       - (Default to be defined): everything except DEBUG into syslog
>       - if debug activate: everything including DEBUG wherever we want (in
> addition to standard syslog)
> 

You can do that. RTM at [1]

For example:
$TYPO3_CONF_VARS['LOG']['writerConfiguration'] = array(
  \TYPO3\CMS\Core\Log\LogLevel::ERROR => array(
    'TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => array(
      'logFile' => 'typo3temp/logs/error.log'
    ),
  ),
  \TYPO3\CMS\Core\Log\LogLevel::DEBUG => array(
    'TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => array(
      'logFile' => 'typo3temp/logs/debug.log'
    ),
  ),
);

Results in:

$ cat typo3temp/logs/debug.log
Thu, 06 Jun 2013 14:21:46 +0200 [DEBUG] request="51b07eda05e52"  ...
Thu, 06 Jun 2013 14:21:46 +0200 [INFO] request="51b07eda05e52"  ...
Thu, 06 Jun 2013 14:21:46 +0200 [NOTICE] request="51b07eda05e52"  ...
Thu, 06 Jun 2013 14:21:46 +0200 [WARNING] request="51b07eda05e52"  ...
Thu, 06 Jun 2013 14:21:46 +0200 [ERROR] request="51b07eda05e52"  ...
Thu, 06 Jun 2013 14:21:46 +0200 [CRITICAL] request="51b07eda05e52"  ...
Thu, 06 Jun 2013 14:21:46 +0200 [ALERT] request="51b07eda05e52"  ...
Thu, 06 Jun 2013 14:21:46 +0200 [EMERGENCY] request="51b07eda05e52"  ...

$ cat typo3temp/logs/error.log
Thu, 06 Jun 2013 14:21:46 +0200 [ERROR] request="51b07eda05e52" ...
Thu, 06 Jun 2013 14:21:46 +0200 [CRITICAL] request="51b07eda05e52"  ...
Thu, 06 Jun 2013 14:21:46 +0200 [ALERT] request="51b07eda05e52"  ...
Thu, 06 Jun 2013 14:21:46 +0200 [EMERGENCY] request="51b07eda05e52"  ...

While writing this, I spotted a bug in the FileWriter which puts
anything into the same file. I will come up with a patch this weekend.

If you think, this documentation is not clear enough, then create a
forge issue for the CoreApi doc.
If you think we need an additional tutorial/howto/best practices
documentation for Logging, then let's start such a document by
collection use cases in the Logging project wiki [2]

> 
> My idea to go one step further but perhaps is not absolutely needed,
> would be this (advanced) use case:
> 
> - configure a logger for method/controller of extension X as DEBUG

I don't think it's a good idea to change severity levels of a log event
at runtime.
You could write any severity of any logger to any LogWriter. But you
have to keep one convention in mind: writers are set for all log levels
which are as severe as or higher than the minimum level and add a writer
to each severity level.
For example if you set:
$TYPO3_CONF_VARS['LOG']['writerConfiguration'] = array(
  \TYPO3\CMS\Core\Log\LogLevel::ERROR => array(
    'TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => array(
      'logFile' => 'typo3temp/logs/error.log'
    ),
  )
);
Then all logRecords of level error, critical, alert and emergency are
writen to that file.


> - what ever happens until the end of the end of the method call (not
> possible without AOP) or until the end of the request (easy), in
> whichever part of the code including Core, should be logged.
> 

sorry, I don't understand this scenario. Could you be more precise?

[1]
http://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Logging/Configuration/Index.html
[2] http://forge.typo3.org/projects/typo3v4-logging/wiki
[3]
http://forge.typo3.org/projects/typo3v4-core/repository/revisions/master/entry/typo3/sysext/core/Classes/Log/Logger.php#L115

-- 
cheers,
Steffen

TYPO3 Blog: http://www.t3node.com/
Twitter: @t3node - http://twitter.com/t3node
_______________________________________________
TYPO3-dev mailing list
[email protected]
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev