[mod_perl] Printen naar logfile werkt niet

Pagina: 1
Acties:

  • Drop
  • Registratie: September 2001
  • Laatst online: 19-02-2022
Ik heb een probleem met het printen naar een logfile in mod_perl. Zonder mod_perl ziet het er zo uit (werkend):

code:
1
2
3
open(LOG, ">>program.log");
print LOG "bla";
close (LOG);


Wanneer ik dit stuk code onder mod_perl draait werkt het niet, er wordt geen logfile aangemaakt. Ik heb begrepen dat mod_perl hiet inderdaad anders te werk gaat (http://take23.org/docs/guide/porting.xml/18) :

In mod_perl both STDIN and STDOUT are tied to the socket the request came from. Because the C level STDOUT is not hooked up to the client, you can re-open the STDOUT filehandler using tie(). For example if you want to dup an STDOUT filehandler and for the code to work with mod_perl and without it, the following example will do:

[code]
use constant IS_MODPERL => $ENV{MOD_PERL};

if (IS_MODPERL) {
tie *OUT, 'Apache';
} else {
open (OUT, ">-");
}
[/code]


Ik heb dit geprobeerd, maar er wordt nog steeds geen logfile aangemaakt. Ik snap ook niet helemaal wat bovenstaand stukje code doet, moet er nergens een filenaam aangegeven worden? Heeft iemand een werkende oplossing?

  • Red Sonja
  • Registratie: Juli 2001
  • Laatst online: 01-07 13:16

Red Sonja

Linux: power to de wortel

Dat stukje over STDIN en STOUT heeft weinig met jouw scripje te maken.
Misschien heb je geen schrijfrechten in die dir?
code:
1
2
3
open(LOG, ">>program.log") or die("Can't write to $LOG: $!\n");
print LOG "bla";
close (LOG);

And the beast shall be made legion. Its numbers shall be increased a thousand thousand fold. The din of a million keyboards like unto a great storm shall cover the earth, and the followers of Mammon shall tremble. from The Book of Mozilla, 3:31


  • Drop
  • Registratie: September 2001
  • Laatst online: 19-02-2022
Ja rechten staan goed, het stuk code werkt prima onder niet-mod_perl.

  • Red Sonja
  • Registratie: Juli 2001
  • Laatst online: 01-07 13:16

Red Sonja

Linux: power to de wortel

En wat krijg je terug als je mijn stukje code probeert ipv die van jou :?

And the beast shall be made legion. Its numbers shall be increased a thousand thousand fold. The din of a million keyboards like unto a great storm shall cover the earth, and the followers of Mammon shall tremble. from The Book of Mozilla, 3:31