News for hackers. Stuff that matters.
Re:Nomad vs. Kubernetes by EdwardDiego on Friday October 15, 2021 @07:43AM (#28876703)
I just wish klog would go die in a fire, I'm so confused at why logging is so terrible in Go.
Re:Nomad vs. Kubernetes by GlennS on Friday October 15, 2021 @08:14AM (#28876897)
Can you expand on this?

My experience with Go has just been making small changes to small programs. So, I don't know what the normal experience is.

My experience with logging varies from:

print (works fine I guess)

import logging (this is pretty good - means I don't have to parse my logs before deciding where to send them)

import slf4j (6 logging frameworks and a logging framework disintermediation framework)

Re:Nomad vs. Kubernetes by EdwardDiego on Friday October 15, 2021 @08:47PM (#28884686)
I elaborated a bit in my reply above, but basically, multiple logging frameworks with incompatible APIs, few of which offer the fine-grained control the person running the app might need.

But I'm used to the JVM world. And when I first met slf4j, I was like, wtf is this crap, but I appreciate it now as the embodiment of the desire to standardise logging across the Java ecosystem.

While using slf4j does make it trivial to swap out logging frameworks in an app, in my 13 years at my last job, we only did that once, from log4j to Logback, so that's not so important.

But yeah, what I miss from Java land in Go logging is the common approach - loggers and appenders are (usually) configured outside of code, the user can provide their own configuration at runtime to override the config shipped in the jar to troubleshoot issues - especially when you can configure the logging lib to check the conf file every X seconds for changes - allows you to change logger levels on the fly without restarting the app (ditto Logback's JMX configurator).

And lastly, no matter the logging library, configuring them is near identical.

Re:Nomad vs. Kubernetes by cpuguy83 on Friday October 15, 2021 @04:51PM (#28882999)
klog is the descendant of glog which is a go implementation of Google's logging. Go has nothing to do with it except it's the logging that k8s took on (originally it used glog).

-- edit typo

Re:Nomad vs. Kubernetes by EdwardDiego on Friday October 15, 2021 @08:32PM (#28884613)
Sorry was referring more to the many different incompatible logging libraries in play.

Also the inability in the ones I've used for the person running the app to set a particular logger to a desired level easily.

I think klog can do this with the vmodules flag, if, and only if, the devs used klog.V() for their logging statements.

Logrus requires the dev to allow the user to configure the log level, common idiom I've encountered is doing so via an env var, but IIRC, that applies to all logging in the app, no way to limit it to particular files/modules.

It's been a real pain at times for me. Feels like the Go philosophy on logging focuses more on the dev controlling it, than the person running it.