11

I have a jenkins master-slave setup through JNLP connections. Everything is working fine except I can not find any logs on the slave nodes. There are logs on the master in $JENKINS-HOME/logs/slaves but none on the slave node.

Can you tell me on which path the log is or if there is even logging on the slave node?

Thank you very much!

Q

devwebcl
  • 2,866
  • 3
  • 27
  • 46
Q-man
  • 115
  • 1
  • 1
  • 6

3 Answers3

13

Jenkins stores all logs on master only, that's why you cannot find any log on nodes.

biruk1230
  • 3,042
  • 4
  • 16
  • 29
  • While this answer is accurate, it isn't helpful. The original question and intents is "where is the log for the slave" You've simply said on the master, but forgot to identify where on the master. – John Rocha Jul 27 '20 at 14:31
  • 3
    @JohnRocha I didn't clarify where, because **author already mentioned it in the question**: '*There are logs on the master in "$JENKINS-HOME/logs/slaves"'*. So I don't know why you think that my answer isn't helpful. – biruk1230 Jul 28 '20 at 07:01
3

On Windows, the slave stores error logs in the same folder as the slave.jar file. This reports things like:

Dec 19, 2018 2:38:14 PM hudson.remoting.Engine waitForServerToBack

"INFO: Failed to connect to the master. Will retry again".

That message will never appear be uploaded to Master.

I would like to see a similar log file on other slaves.

Community
  • 1
  • 1
Robert Echlin
  • 623
  • 5
  • 6
  • You might need to add the [`-workDir`](https://github.com/jenkinsci/remoting/blob/master/docs/workDir.md) or `-agentLog` argument to the `java` command line. As that link says: "Before Remoting 3.8 (Jenkins 2.68)... Logs are not being persisted to the disk unless -agentLog option is specified." See the link for more docs. – qris Jan 22 '21 at 11:30
  • @qris Can we set global environmental variables JENKINS_JAVA_OPTS or JAVA_OPTS (github.com/jenkinsci/remoting/blob/master/docs/logging.md) to redirect slave agent logs to STDOUT? I'm trying to get all logs to container logs rather than to master node? Is it possible? (https://stackoverflow.com/questions/74588466/jenkins-agent-logs-to-stdout-of-docker-aws-eks-container-is-it-possible) Thanks – Shanthi Nov 29 '22 at 02:46
2

They are mostly transferred to Master by TCP. For example, when a step starts, like a shell task, will do like this

  1. call your shell content
# your script will be transform into a script file
script.sh > jenkins-log.txt
# running...
# after running
echo $? > jenkins-result.txt
  1. during the running progress, data will be transport by TCP(pull or push)
jenkins-log.txt -> Filestream -> RemoteStream -> Master

and in master, you will see single log like it

jobs/xxx/branch/master/<id>/log
  1. When job is done, master will send the command to clean the temp dir in the agent, so you can't see anything about logs.

One more thing, in our company, we are facing the problem of too much logs are being sent to Master like a DDOS, so a simple way to solve is to add a pipeline after the shell

limit by tail

xxx | tail -c 512k 

or limit the size by head command

xxx | (head -n 1000;dd status=none of=/dev/null)
Miao1007
  • 944
  • 6
  • 22