This simple service will run a centralised log server which can receive messages over UDP from applications and store them in a file.
- You must have Ruby install on your host (1.8.7 or 1.9.3 are currently supported)
- An internet connection
git clone https://github.com/atech/log-server.git /opt/log-server
ln -s /opt/log-server/upstart.conf /etc/init/log-server.conf
start log-serverAll logs by default are stored in /opt/log-server/logs/app_name/log_name.log.
The following code outlines how to send a message to the log server. You should replace 1.2.3.4 with
the IP address of your installed log server.
app_name = 'sirportly'
log_name = 'workers'
message = "Hello there! This is a test of my log server..."
socket = UDPSocket.new
data = [app_name.bytesize, app_name, log_name.bytesize, log_name, message.bytesize, message, 0].pack('nA*nA*nA*n')
socket.send(data, 0, '1.2.3.4', 4455)This works well with our log server IO class which can easily be used with loggers.
logger = Logger.new(Atech::NetworkLogIO.new(:host => '1.2.3.4', :app_name => 'demo', :log_name => 'app'))