[email protected]
[Top] [All Lists]

Re: Logging to one file per user

Subject: Re: Logging to one file per user
From: "Marco V."
Date: Thu, 2 Nov 2006 10:12:27 +0100
> Hi,
> 
> For a website I need to have a log file per user.
> 
> I first looking into NDC by this make only one file with some informations (I 
> test with session id).
> 
> After I've try to create a file logger and change the name but that doesn't 
> work. here's the code :
> ----------8<-----------
> $oUserLogger = LoggerManager::getLogger('userLog');
> $oAppender = $oUserLogger->getAppender( 'userFile' );
> $sLogFile  = sprintf('system/logs/users/%s.log',session_id() );
> $oAppender->setFile($sLogFile);
> 
> ----------8<-----------
> 
> So anybody has an idea to make a log file per user ?

Try to change your code like this (use & to reference objects in PHP4; with 
php5 you can omit them):

$oUserLogger =& LoggerManager::getLogger('userLog');
$oAppender =& $oUserLogger->getAppender( 'userFile' );
$oAppender->close();
$sLogFile  = sprintf('system/logs/users/%s.log',session_id() );
$oAppender->setFile($sLogFile);
$oAppender->activateOptions();

the close() method closes the file opened by logger configurator; then 
activateOptions() open the file $sLogFile.

Regards,
-Marco

<Prev in Thread] Current Thread [Next in Thread>
  • Re: Logging to one file per user, Marco V. <=