Difference between revisions of "错误处理"

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search
Tag: 2017 source edit
Line 43: Line 43:
  
 
=其他不常见的系统日志=
 
=其他不常见的系统日志=
 +
==Webserver logs==
 +
===Apache===
 
请注意,除了syslog模块之外,您还可以在Apache日志中找到PHP/Apache技术错误(无论syslog模块的状态/配置如何)。但这仅发生在安装或环境的技术问题上。一个正常工作的 Dolibarr 应用程序永远不会显示这些文件中的任何内容。在标准的 Linux 系统上,这些痕迹可以在 '''/var/log/apache[2]/[dolibarr]-error.log''' 文件中看到。您可以使用以下命令从终端实时查看它们:
 
请注意,除了syslog模块之外,您还可以在Apache日志中找到PHP/Apache技术错误(无论syslog模块的状态/配置如何)。但这仅发生在安装或环境的技术问题上。一个正常工作的 Dolibarr 应用程序永远不会显示这些文件中的任何内容。在标准的 Linux 系统上,这些痕迹可以在 '''/var/log/apache[2]/[dolibarr]-error.log''' 文件中看到。您可以使用以下命令从终端实时查看它们:
 
=Webserver logs=
 
==Apache==
 
Note that you can have also find some technical PHP/Apache errors in apache log file (whatever is status/setup of this module). But this occurs only if there is a technical problem in your installation: On a typical Linux install, such logs will be available somewhere in '''/var/log/apache[2]/[dolibarr]-error.log'''. You can watch it ''live'' from the terminal by using:
 
 
<syntaxhighlight lang="bash">tail -f /var/log/apache2/dolibarr-error.log</syntaxhighlight>
 
<syntaxhighlight lang="bash">tail -f /var/log/apache2/dolibarr-error.log</syntaxhighlight>
==Nginx==
+
===Nginx===
 
If you are using nginx to serve Dolibarr some useful debugging information is often to be found there.
 
If you are using nginx to serve Dolibarr some useful debugging information is often to be found there.
 
<syntaxhighlight lang="bash">tail -f /var/log/nginx/error.log</syntaxhighlight>
 
<syntaxhighlight lang="bash">tail -f /var/log/nginx/error.log</syntaxhighlight>

Revision as of 02:28, 27 September 2023

函数

在 Dolibarr 日志文件中记录日志信息的函数:

dol_syslog($message, LOG_DEBUG|LOG_INFO|LOG_WARNING|LOG_ERR);

日志级别与 Syslog 模块(见下文)中定义的设置相关。

在屏幕上显示错误消息的函数(必须在从不到达的代码中保留使用):

dol_print_error($db,texte);

Syslog调试日志模块

跟踪模块包含在Dolibarr的其他可管理模块中,允许您启用/更改要查看的错误级别。

要访问此模块的配置页面,请转到 主页->设置->模块/应用,然后单击syslog调试日志模块行行末尾的齿轮图标。

当然,必须启用此模块(Syslog)才能进行跟踪工作。

Syslogfacility 选项是用于记录消息的预定义配置概念。这是一个系统功能,用于告诉系统操作员错误来自何处(此处为dolibarr),并指示其优先级。您可以在PHP文档中找到dol_syslog()函数中使用的openlog()函数的更多信息:http://www.php.ne/openlog

通常,除非您知道自己在做什么,否则应将此值保留为 LOG_USER

下一个选项 file 允许您选择要保存日志的文件。指定的路径必须相对于根(/)目录。如果保持原样(默认选项DOL_DOCUMENT_ROOT/dolibarr.log),它将在 Dolibarr 的 documents 目录中创建。当然,要做到这一点,您的web服务器必须对该目录具有写入权限。

通常,file 设施将更频繁地工作,因为它不依赖于服务器的系统配置,也不依赖于可能需要的syslog守护进程(唯一可能发生的问题是web服务器没有对目录的写入权限)。

最后,日志级别表示您希望看到多少种类型的消息。LOG_DEBUG(7) 是最详细的选项,它会打印通过dol_syslog()函数传递的任何消息。LOG_EMERG(0) 正好相反,只跟踪严重错误的消息。

有关更多详情,请参阅 Module Syslog (developer) 页面。

其他不常见的系统日志

Webserver logs

Apache

请注意,除了syslog模块之外,您还可以在Apache日志中找到PHP/Apache技术错误(无论syslog模块的状态/配置如何)。但这仅发生在安装或环境的技术问题上。一个正常工作的 Dolibarr 应用程序永远不会显示这些文件中的任何内容。在标准的 Linux 系统上,这些痕迹可以在 /var/log/apache[2]/[dolibarr]-error.log 文件中看到。您可以使用以下命令从终端实时查看它们:

tail -f /var/log/apache2/dolibarr-error.log

Nginx

If you are using nginx to serve Dolibarr some useful debugging information is often to be found there.

tail -f /var/log/nginx/error.log