Log Format and Log Redirection


Can we configure LogFormat of linkerd logs? Also is there way to redirect logs that linkerd writes to console to a file with our format?
Or is there a way to supply our log impl that you can use for logging?



There is an open issue to make access log format configurable: https://github.com/linkerd/linkerd/issues/294

But as far as I know, no one is actively working on this.


Ok. That story looks like for access log, Or is it also for logs that are
printed on console?


Ah, yeah, that issue related to access logs. But the situation is similar for regular logs: we don’t have any immediate plans to make this configurable but we would probably accept a PR if you wanted to work on this.


Sure. Let me look at it and see if I can make some progress. I can look at
the code and search but can you point me to the log class that writes
console logs?

Also can you please tell me if you follow any current pattern and if yes
what it is?



Yeah! Sounds great. We use the com.twitter.logging package for logging: https://github.com/twitter/util/tree/develop/util-logging/src/main/scala/com/twitter/logging

We also have a log4j properties file: https://github.com/linkerd/linkerd/blob/master/linkerd/main/src/main/resources/log4j.properties

I have a hard time keeping track of how these logging libraries interact with each other, but hopefully this is enough to get you started.


Thanks this helps. Do you know why INFO level logs are coming on to console
when the root logger is configured with WARN?

I see the following lines which are INFO lines on the console when I start
I 0731 11:12:06.652 UTC THREAD1: serving http admin on /
I 0731 11:12:07.072 UTC THREAD1: serving incoming_http2 on /
I 0731 11:12:07.181 UTC THREAD1: serving outgoing_http1 on /
I 0731 11:12:07.194 UTC THREAD1: serving outgoing_http2 on /
I 0731 11:12:07.202 UTC THREAD1: initialized


If I go to linkerd admin, it shows the configured log level as INFO. Then
is it not using this log4j.properties?


Good question. I don’t know the answer off the top of my head. I know that log level can definitely be configured with the -log.level flag and through the logging UI in the linkerd admin. But I don’t know how this interacts with the log4j.properties file.


Thanks. I think I got it. The twitter logging class is actually using java util logger instead of log4j. That is why even though we have warn in log4j.properties we are getting INFO level logs. I was able to control format by supplying logger.properties in JUL format…Thanks for your help on this…


Awesome, nice work!!

closed #12

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.