Photon OS linux 上的日志记录方法 - 我的应用程序日志文件不是由应用程序在指定位置创建的

Logging Methods on Photon OS linux -my app log file is not created on the specified location by the application

我有一个用 golang 编写的小应用程序,我提到了创建日志文件以跟踪应用程序流程的路径。但是一旦应用程序启动,日志文件就会在我的 ubuntu fedora 版本上创建,但是日志不会在 photon OS vm ware 上创建,并且也没有显示错误。

这是我的代码,运行良好,仅供参考。

f, err := os.OpenFile("/var/log/pluginlog.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
    return err
    logical.ErrorResponse("Error:creating log file " + err.Error())
    fmt.Sprintf("error", err)
}
defer f.Close()
loggr := log.New(f, "prefix", log.LstdFlags)
loggr.Println(logv)
return err

我浏览了一些可用于 photon 的文档 os,上面写着

On Photon OS, all the system logs except the installation logs and the cloud-init logs are written into the systemd journal. The journalctl command queries the contents of the systemd journal.

这意味着我的日志也会在日志中添加一个条目吗?

但如果是这样,我该如何访问该特定日志?

(该应用程序是为 hashicorp-vault 开发的插件,插件与 vault 环境一起运行。) 如果请帮助我,任何人都知道吗? 提前致谢。

解决了这个问题。实际上代码并没有抛出错误。实际上我在访问日志路径时遇到了权限错误。并了解到我们也可以在 photon os linux 版本上创建单独的日志文件,而不是写入日志。