python wsgi信息log进入apache2 error.log
我有一个在Apache上运行的WSGI应用程序。但是我有一个小问题很烦人。我所有的日志都进入了error.log apache2文件,即使是信息日志。
这是我的日志类,如果您有和想法,请提前
class Log:
def __init__(self, path, smtp):
self.smtp = smtp
self.filename = ''
self.LOGGER = logging.getLogger('Open-Capture')
if self.LOGGER.hasHandlers():
self.LOGGER.handlers.clear() # Clear the handlers to avoid double logs
log_file = RotatingFileHandler(path, mode='a', maxBytes=5 * 1024 * 1024,
backupCount=2, encoding=None, delay=False)
formatter = logging.Formatter(
'[%(name)-17s] [%(file)-26sline %(line_n)-3s] %(asctime)s %(levelname)s %(message)s',
datefmt='%d-%m-%Y %H:%M:%S')
log_file.setFormatter(formatter)
self.LOGGER.addHandler(log_file)
self.LOGGER.filters.clear()
self._filter = CallerFilter()
self.LOGGER.addFilter(self._filter)
self.LOGGER.setLevel(logging.DEBUG)
@caller_reader
def info(self, msg):
self.LOGGER.info(unidecode(msg))
,这是我的Apache2配置
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html/opencapture_runtime/
WSGIDaemonProcess opencapture_runtime user=nathan group=nathan threads=5
WSGIScriptAlias /runtime /var/www/html/opencapture_runtime/opencapture.wsgi
<Directory /var/www/html/opencapture_runtime/>
AllowOverride All
WSGIProcessGroup opencapture_runtime
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
示例Apache Log:
[Wed Jul 06 10:25:23.577457 2022] [wsgi:error] [pid 37073] [remote ::1:42356] INFO:Open-Capture:Authentification successful. IP Address : ::1
I have a WSGI app running on Apache. But I have a little issue pretty annoying. All my logs goes into the error.log apache2 file, even if it's INFO log.
Here is my Log class, if you have and idea, thanks in advance
class Log:
def __init__(self, path, smtp):
self.smtp = smtp
self.filename = ''
self.LOGGER = logging.getLogger('Open-Capture')
if self.LOGGER.hasHandlers():
self.LOGGER.handlers.clear() # Clear the handlers to avoid double logs
log_file = RotatingFileHandler(path, mode='a', maxBytes=5 * 1024 * 1024,
backupCount=2, encoding=None, delay=False)
formatter = logging.Formatter(
'[%(name)-17s] [%(file)-26sline %(line_n)-3s] %(asctime)s %(levelname)s %(message)s',
datefmt='%d-%m-%Y %H:%M:%S')
log_file.setFormatter(formatter)
self.LOGGER.addHandler(log_file)
self.LOGGER.filters.clear()
self._filter = CallerFilter()
self.LOGGER.addFilter(self._filter)
self.LOGGER.setLevel(logging.DEBUG)
@caller_reader
def info(self, msg):
self.LOGGER.info(unidecode(msg))
And here is my apache2 config
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html/opencapture_runtime/
WSGIDaemonProcess opencapture_runtime user=nathan group=nathan threads=5
WSGIScriptAlias /runtime /var/www/html/opencapture_runtime/opencapture.wsgi
<Directory /var/www/html/opencapture_runtime/>
AllowOverride All
WSGIProcessGroup opencapture_runtime
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
Example of apache log :
[Wed Jul 06 10:25:23.577457 2022] [wsgi:error] [pid 37073] [remote ::1:42356] INFO:Open-Capture:Authentification successful. IP Address : ::1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论