ab und zu (so alle ein bis zwei Wochen) kommt es vor, dass es beim Loggen zu einer Fehlermeldung kommt und das Logging anschließend abgeschaltet ist:
(7) Warning: fopen(C:\IP-Symcon\logs\IPSLogger_20170105.xml): failed to open stream: Permission denied
Error in Script C:\IP-Symcon\scripts\IPSLibrary\app\core\IPSLogger\IPSLogger_Output.inc.php on Line 53
134 in scripts\IPSLibrary\app\core\IPSLogger\IPSLogger.inc.php (call IPSLogger_Out)
39 in scripts\IPSLibrary\app\core\IPSLogger\IPSLogger_PhpErrorHandler.inc.php (call IPSLogger_Err)
in IPSLogger_PhpErrorHandler
53 in scripts\IPSLibrary\app\core\IPSLogger\IPSLogger_Output.inc.php (call fopen)
101 in scripts\IPSLibrary\app\core\IPSLogger\IPSLogger_Output.inc.php (call IPSLogger_WriteFile)
in IPSLogger_OutLog4IPS
506 in scripts\IPSLibrary\app\core\IPSLogger\IPSLogger_Output.inc.php (call call_user_func_array)
39 in scripts\IPSLibrary\app\core\IPSLogger\IPSLogger_Output.inc.php (call IPSLogger_invokeLoggers)
205 in scripts\IPSLibrary\app\core\IPSLogger\IPSLogger.inc.php (call IPSLogger_Out)
71 in scripts\WOL.ips.php (call IPSLogger_Trc)
31 in scripts\WOL.ips.php (call online)
Ich vermute, dass in dieser Situation zwei Threads gleichzeitig schreiben wollen.
Ich habe die Funktion ‚IPSLogger_WriteFile‘ daher bei mir um eine Semaphore erweitert:
function IPSLogger_WriteFile($Directory, $File, $Text, $ID_OutEnabled) {
if ($Directory == "") {
$Directory = IPS_GetKernelDir().'logs/';
if (function_exists('IPS_GetLogDir'))
$Directory = IPS_GetLogDir();
}
//Semaphor eingebaut um einen zeitgleichen Zugriff ("Warning: fopen ...: failed to open stream: permission denied")
//zu verhindern.
//Da im Fall eines 'Parse Errors' keine Semaphore erhältlich ist ('Warning: Cannot detect ThreadID!')
//sollten die Warnings unterdrückt werden (@)
@IPS_SemaphoreEnter(__FUNCTION__.$Directory.$File, 1000);
if(($FileHandle = fopen($Directory.$File, "a")) === false) {
SetValue($ID_OutEnabled, false);
@IPS_SemaphoreLeave(__FUNCTION__.$Directory.$File);
return;
}
fwrite($FileHandle, $Text.c_lf);
fclose($FileHandle);
@IPS_SemaphoreLeave(__FUNCTION__.$Directory.$File);
}
Seitdem ist Ruhe:)
Wäre schön, wenn du die Änderungen übernehmen könntest.
ich nutze wegen der guten Filtermöglichkeiten gerne ‚Log4IPS‘ in Verbindung mit Log4View. Dabei sind mir zwei Fehler aufgefallen, die ich in der Funktion IPSLogger_OutLog4IPS behoben habe: