Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 快速远程记录系统?_Python_Linux_Logging_Command Line - Fatal编程技术网

Python 快速远程记录系统?

Python 快速远程记录系统?,python,linux,logging,command-line,Python,Linux,Logging,Command Line,我想使用(Linux)命令行或Python将一些日志快速插入到一些测试中。我不想在系统范围内做任何事情(例如重新配置syslogd) 我以前也做过类似的事情: wget URL/logme?im=module\u name&msg=hello\u world 然后只是解析服务器日志文件。这有点黑客,你必须对所有数据进行URL编码。现在肯定有人有更好的办法了 有更好的方法快速获取远程日志吗?您可以使用远程系统日志服务器:rsyslog或python包loggerglue实现rfc5424和rfc5

我想使用(Linux)命令行或Python将一些日志快速插入到一些测试中。我不想在系统范围内做任何事情(例如重新配置syslogd)

我以前也做过类似的事情:

wget URL/logme?im=module\u name&msg=hello\u world

然后只是解析服务器日志文件。这有点黑客,你必须对所有数据进行URL编码。现在肯定有人有更好的办法了


有更好的方法快速获取远程日志吗?

您可以使用远程系统日志服务器:rsyslog或python包loggerglue实现rfc5424和rfc5425中描述的系统日志协议。当您使用1024以上的端口时,可以作为非root用户运行它

在python日志模块中,您有一个SyslogHandler,它还支持syslog远程日志记录

import logging
import logging.handlers

my_logger = logging.getLogger('MyLogger')
my_logger.setLevel(logging.DEBUG)

handler = logging.handlers.SysLogHandler(address = ('127.0.0.1',514))

my_logger.addHandler(handler)

my_logger.debug('this is debug')
my_logger.critical('this is critical')

你不愿意在整个系统内改变双方的安东尼吗?否则,您可以将rsyslog设置为日志服务器,并将python“loggerglue”设置为从客户端登录到远程主机。我想要一些不需要root权限就可以安装的东西。如果我可以在非特权端口上运行系统日志,那么应该可以。