Home: Perl Programming Help: Intermediate:
Log4Perl - many servers logging to one log-server



Spinner
Novice

Nov 9, 2012, 2:17 AM


Views: 6722
Log4Perl - many servers logging to one log-server

I have the following challenge:

My system uses a number of backend-webservers and a few non-web-servers. I would like for them all to log certain actions to a common log that lies on a log-server.
I would very much like the log to look like:
TIMESTAMP FROM-HOSTNAME LOGSTRING
but I can ofc insert the hostname in each logstring myself if need be.

I have used Log4Perl for years, but I know of no way to make them all use a common log-server to store the data. I AM aware of logging to a socket, but I guess I would need to write a server myself that deals with incoming requests on a certain port, and I was hoping Log4Perl would be able to do this automatically for me.

So, can it?

Is there another log-package I should be looking at more suited for doing this?

How do you solve your needs to keep a common log from multiple servers without storing the data in a database?

With hopes of response.

- Spinner


FishMonger
Veteran / Moderator

Nov 9, 2012, 6:41 AM


Views: 6717
Re: [Spinner] Log4Perl - many servers logging to one log-server


Quote
How do you solve your needs to keep a common log from multiple servers without storing the data in a database?

I would argue for using a database.

This one is on the old side, but is probably still ok.
Log::Dispatch::DBI - Class for logging to database via DBI interface
http://search.cpan.org/~miyagawa/Log-Dispatch-DBI-0.02/lib/Log/Dispatch/DBI.pm

This is a newer one and will probably be a better choice.
Log::Log4perl::Appender::DBI - implements appending to a DB
http://search.cpan.org/~mschilli/Log-Log4perl-1.39/lib/Log/Log4perl/Appender/DBI.pm

If you don't want to go the DB route, then on each server use an NFS mount to access the log-server and then write to the logfile as if it were local.


Spinner
Novice

Nov 9, 2012, 7:00 AM


Views: 6714
Re: [FishMonger] Log4Perl - many servers logging to one log-server

Thank you very much.

I had not even considered the NFS-solution, good idea indeed!

I shall ponder some more on the DB-route, the main reason for wishing to avoid this is load, as in up towards 200 appends per second in some cases...