[Tutor] Writing to a remote file

Python python at venix.com
Mon Jun 19 14:40:19 CEST 2006


On Sun, 2006-06-18 at 20:11 +0100, kieran flanagan wrote:
> Hi 
>  
> Thanks for the help. I took a quick scan through the logging module
> and I can't see any mention of writing to a remote file ? Could you
> please direct me to the part you mentioned ?. 

I had 3 suggestions: use the remote computer as a file server, use the
remote server as a syslog server, write your own logging server on the
remote computer.

1.  If the remote system is a file server, the logging module does not
know it is writing to a remote computer.  The remote computer is simply
mounted into your local file system.  You'd use linux commands something
like:
	mkdir logfiles
	mount -t smbfs //remote/logs ./logfiles
That assumes the remote computer is running samba.  The Python code
would be something like:
	import logging, logging.handlers
	logger = logging.getLogger('')
	logger.addHandler(logging.handlers.FileHandler('logfiles/myapp.log'))
(all this is untested, but, hopefully, close to being correct)

2.  You eliminate the remote syslog option below.

3.  Write your own logging server to run on the remote computer.  Have
your local program use the remote logging server.  The example code is
here:
	http://docs.python.org/lib/network-logging.html

> I went through some of the examples and the one related to remote
> logging is via the console (tcp port). I cannot see any information
> given regarding remote logging.
> Just to give some more info on what I am doing. I have a large script
> that is running and outputting messages to a logfile I am storing. I
> want these messages to be output to a remote file instead which can be
> viewed on a browser to provide realtime data as the script processes.
> So this logfile is not handled by syslog.
>  
> This is being done on a Linux machine.
>  
> Thanks for the help
> Kieran
>  
> 
> 
>  
> On 6/16/06, Lloyd Kvam <lkvam at venix.com> wrote: 
>         On Fri, 2006-06-16 at 14:47 +0100, kieran flanagan wrote:
>         > Hi
>         >
>         > I want to run a script on one machine and log output
>         messages to a 
>         > remote file located on another machine. Is there any easy
>         method of
>         > doing this ?.
>         
>         http://docs.python.org/lib/module-logging.html
>         
>         If the remote machine is a file server, you can use the
>         logging module
>         to write to a file on the remote machine
>         
>         Also the logging module can be used to easily log to a syslog
>         handler.
>         If this remote file is a "normal" log file managed by a syslog
>         process 
>         then you should find the python part pretty easy.  The syslog
>         process
>         still needs to be configured to accept your logging messages,
>         but that
>         should not be too difficult.
>         
>         Scanning the logging module docs, it looks like you can use it
>         to write 
>         your own process to run on the remote machine to handle
>         "logging
>         messages".  Then use the logging module on the local machine
>         to send
>         "logging messages" to the remote machine.
>         
>         
>         > Thanks 
>         > Kieran
>         >
>         > --
>         > "Behind every great man, there is a great woman. Behind that
>         woman is
>         > Mr.T."
>         > _______________________________________________
>         > Tutor maillist  -   Tutor at python.org
>         > http://mail.python.org/mailman/listinfo/tutor
>         --
>         Lloyd Kvam
>         Venix Corp.
>         1 Court Street, Suite 378 
>         Lebanon, NH 03766-1358
>         
>         voice:  603-653-8139
>         fax:    320-210-3409
>         
> 
> 
> 
> -- 
> "Behind every great man, there is a great woman. Behind that woman is
> Mr.T." 
-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:  603-653-8139
fax:    320-210-3409
-- 
Lloyd Kvam
Venix Corp



More information about the Tutor mailing list