如何将jenkins.security.SecurityListener日志重定向到Linux主机上的日志文件

huangapple go评论80阅读模式
英文:

How to redirect jenkins.security.SecurityListener logs to a log file on a linux host

问题

我已在我的Jenkins服务器上为jenkins.security.SecurityListener日志设置了记录器。我可以在Web门户中查看这些日志,但我找不到它们在服务器上的存储位置。我希望能够在服务器上访问这些日志。

英文:

I have setup a logger on my jenkins server for jenkins.security.SecurityListener logs. I can view the logs in the webportal but I cannot find where the are stored on the server. I want to be able access these logs on the server.

答案1

得分: 1

我遇到了同样的问题 - 希望将 jenkins.security.SecurityListener 的输出重定向到文件。

在我的实现中,我在 AWS 上将 Jenkins 作为 ECS Fargate 任务运行。/var/jenkins_home 目录被挂载到一个 EFS 文件系统上。我还有一个 CloudWatch 代理与 Jenkins 一起运行,挂载了相同的 EFS 访问点。因此,任何写入 EFS 的日志都可以被轮询/监视并传输到 CloudWatch。

我找到的最佳解决方案涉及安装 'Support Core' 插件 - 它会自动将所有日志(包括在 System Log -> Log Recorders 中的自定义配置)重定向到 /var/jenkins_home/logs,以及一系列附加功能。

注意:此插件不会将容器日志(通过 docker logs <container_id> 可见)写入文件,为了在 Jenkins UI 之外捕获/查看这些日志,需要将 AWS 的多个日志驱动程序之一应用于您的 ECS 任务。

这里 是我找到答案的页面。

英文:

I had the same issue -- wanted to redirect jenkins.security.SecurityListener output to a file.

In my implementation I have Jenkins running on AWS as an ECS Fargate task. The /var/jenkins_home directory is mounted to an EFS filesystem. I also have a CloudWatch agent running alongside Jenkins mounting the same EFS access point. Any logs written to EFS can therefore be polled/monitored and transferred to CloudWatch.

The best solution I found involved installing the 'Support Core' plugin -- it automatically redirects all logs (including custom configurations in System Log -&gt; Log Recorders) into /var/jenkins_home/logs as well as a host of additional features.

Caveat: the container logs (visible via docker logs &lt;container_id&gt;) are not written to a file by this plugin, to capture/view these outside the Jenkins UI, one of several AWS Log Drivers needs to be applied to your ECS task.

Here is the page where I found the answer.

答案2

得分: -1

当你在谈论在 Web 门户中查看日志时,是否是指控制台输出?如果是这种情况,有一些选项。

对于 Jenkins 构建日志,默认情况下日志应该位于 /var/log/jenkins/jenkins.log,除非在 /etc/default/jenkins(对于 *.deb)或通过 /etc/sysconfig/jenkins(对于 */rpm)中进行了定制。

另一个选项是使用 curl 或 wget 命令在 Linux 服务器上将日志下载到本地。

curl http://jenkinsUrl/job/<Build_Name>/<Build_Number>/consoleText -OutFile

另一个常见的位置是:
${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/log

你还可以使用插件来捕获 Jenkins 控制台日志,并根据你的选择将它们存储在服务器上的任何位置。有针对此功能的插件可用。

谢谢,
Subhadeep

英文:

When you are talking about seeings logs in webportal, are you talking about console output? In that case there are some options.

For jenkins build logs,By default logs should be made available in /var/log/jenkins/jenkins.log , unless customized in /etc/default/jenkins (for *.deb) or via /etc/sysconfig/jenkins (for */rpm).

Another option is to download them in your linux server using curl or wget command.

curl http://jenkinsUrl/job/<Build_Name>/<Build_Number>/consoleText -OutFile <FilePathToLocalDisk>

another common location:
${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_NUMBER}/log

You can use plugins also to capture jenkins console logs and store them in any location in server as per your choice. Plugins are available for that.

Thanks,
Subhadeep

huangapple
  • 本文由 发表于 2020年9月20日 01:32:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/63971580.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定