- Daemon.*-/var/log/daemon.log
Copy CodeDefines the location where logs generated by Daemon are saved, where daemon is the log type, and "*" means that all levels of logs are placed in the file. The format is: facility. Level-the path where log files are saved, such as-/var/log/daemon.loglevel include:
- Local4.info-/var/log/
Copy CodeNext, execute the command/etc/init.d/sysklogd restart or/etc/init.d/sysklogd reload make the new configuration effective. Start testing the new log rule: 1, enter the command
- Logger-p local4.info "My test Log"
Copy Code2, execute command
- Tail/var/log/event_log.log
Copy CodeYou can see the log information you wrote: Note: syslog.conf local4.info represents all info levels and the above logs are recorded here. In this, the required logs have been set up in Ubuntu. The following starts using Syslog in PHP to write the logs to the syslog in Ubuntu. The reference code is as follows:
Note: The first parameter of Openlog, which is the log ID, is automatically added to the beginning of the log information to indicate what the system writes to the log. Because here you want to write the log to Local4.info, the third parameter needs to use LOG_LOCAL4, which represents the device information written to the log. The $level in the syslog is the log level, which includes: Log_emerg system is Unusablelog_alert action must be taken Immediatelylog_crit critical conditionslog_err error conditions Log_warning WARNING Conditionslog_notice Normal, but significant, conditionlog_info informational Messagelog_debug Debug-level messageThe second parameter is a specific log content. About PHP to write logs to the Syslog method, the introduction of these bar, I hope to be helpful to everyone. |