Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm in need of some logging wisdom... I would like to build an application that will have multiple remote hosts logging activity to a central server. There are a few slick logging modules but none seemed to natively support remote logging.

I'd like to do something like the following:

remotelog("remote_host", "This is my message");

or

my $log = Log->get_logger("RemoteHost::Server"); $log->debug("I'm broken");
Could anyone shine some light on this dark path ahead!?

-Beev

Replies are listed 'Best First'.
Re: Logging to a Remote Host
by waswas-fng (Curate) on Dec 17, 2002 at 23:48 UTC
    What OS? if unix you may find that syslog will do this very well, you may use modules from CPAN such as Tie::Syslog to make pushing to syslog as easy as print LOG "Error, did not open blah\n"; then you may configure syslog to point to a syslog master host that accepts syslog messages from all o the slaves and logs them centrally. Also if the clients are windows or a mix and the logging master is unix you may use Net::Syslog to directly post syslog messages to a syslog server.

    -Waswas
Re: Logging to a Remote Host
by tachyon (Chancellor) on Dec 17, 2002 at 23:47 UTC

    What you have is a client server problem. Just set up a server listening on some high port on the logging machine and write a simple client to talk to it. HTTP::Daemon would do for a server with LWP acting as the client. You should be able to do it in under 20 lines using these modules. Here is a simple server...

    use HTTP::Daemon; use HTTP::Status; $d = new HTTP::Daemon LocalAddr => 'www.someplace.com', LocalPort => 12345; while (my $c = $d->accept) { while (my $r = $c->get_request) { log( $r ); $c->send_basic_header( 200, 'OK' ); } $c->close; undef $c; } sub log { my $request = shift; # you get the standard request object here, so have a look.... use Data::Dumper; print Dumper $request # do whatever - you can parse out whatever you want from the $requ +est hash }

    There are any number of LWP examples floating about.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print