views:

162

answers:

3

I have a system where a central Java controller launches analysis processes, which may be written in C++, Java, or Python (mostly they are C++). All these processes currently run on the same server. What are you suggestions to

  • Create a central log to which all processes can write to
  • What if in the future I push some processes to another server. How can I support distributed logging?

Thanks!

+3  A: 

I'd recommend using the platform's native logger which is syslog on Posix and Event Log on Windows.

For C++, you can use the native calls on the platform.

I know Python comes with syscall wrapper on Posix and there are wrappers for Event Log in the PyWin32 extension. I assume that someone has created Java wrappers by now.

Update

Regarding syslog and multiple files. syslog support the concept of facilities - via facilities you can have different logs go to different files. Unfortunatley, facilities are predefined; while there are 8 generic ones LOG_LOCAL0 through LOG_LOCAL7 you cannot define arbitrary facilities.

Also note that it's up to the syslog daemon to decide where to route log messages for each facility / level. You may need to adjust your syslog daemon configuration to have each facility get sent to a different file.

R Samuel Klatchko
Thanks for the answer. Can you create separate syslog logs on the same machine? We have different services, each with a number of processes and we want to keep the logs separate ideally.
recipriversexclusion
@recipriversexclusion - updated answer to answer your comment.
R Samuel Klatchko
Another nice thing about syslog is that all reasonable implementations already know how to send log messages across the network to another machine.
Forest
+1  A: 

Apache has cross-platform logging libraries, which allow you to log from various programming languages using similar APIs. Unfortunately they don't have a Python API, though you should be able to whip one up with log4cpp and Boost.Python.

A project I work on uses one of these libraries to log to a database, which allows us "distributed logging" with a centralized place for the log messages. I have to admit I'm not a fan of this. Another project I work on uses one of these libraries to log to the native logging facility. The Windows Event Log has some features for distributed logging, but AFAIK syslog does not.

Although I don't have any experience with it, a better fit may be Facebook's Scribe project. The feature set meets your requirements, including a Python API. Unfortunately it uses Thrift which doesn't work for C++ on Windows (that is, the Thrift compiler generates C++ code that only works on UNIX). You may be able to get around this problem using Cygwin, but I can't promise that approach will work.

Max Lybbert
syslog supports distributed logging. The classic syslogd supports forwarding messages to another host with the `@hostname` syntax. See "Remote Machine" section in the syslog.conf man page: http://linux.die.net/man/5/syslog.conf
R Samuel Klatchko
Scribe looks very interesting, am looking into it right now.
recipriversexclusion
A: 

I'd use Apache log4cxx or Apache log4j. It's Efficient. It has Logger hierarchies to modularize your logs. It's proven tecnology for a while now. Currently, appenders exist for the console , files , GUI components, remote socket servers, NT Event Loggers , and remote UNIX Syslog daemons. It is also possible to log asynchronously.

How can I support distributed logging? With remote socket servers appenders for example.