Go version

1.25.1

Output of go env in your module/workspace:

AR='ar'
CC='aarch64-linux-gnu-gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='0'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build190822621=/tmp/go-build -gno-record-gcc-switches'       
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/go.mod'
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.25.1'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

With the provided code at https://github.com/stunney/bug_golang_slog_armv8_processdeath

I create a armv8 container for my program which is compiled to on an armv8 platform, explicitly targeting ARMv8.

Here is my simple main.go that I have extracted from a larger project to show the issue:

package main

import (
    "log"
    "log/slog"
    "os"

    "github.com/natefinch/lumberjack"
)

func ConfigureServiceLogging() {
    log.Println("ConfigureServiceLogging::start")

    log.Println("ConfigureServiceLogging::defineRotator")
    // Configure Lumberjack for log rotation
    logRotator := &lumberjack.Logger{
        Filename:   os.Getenv("LOG_DIR"), // Name of the log file
        MaxSize:    10,                   // Max size in megabytes before rotation
        MaxBackups: 3,                    // Max number of old log files to keep
        MaxAge:     7,                    // Max number of days to retain old log files
        Compress:   true,                 // Compress old log files
    }

    log.Println("ConfigureServiceLogging::defineHandler")

    // Create a slog handler that writes to the Lumberjack rotator
    handler := slog.NewJSONHandler(logRotator, &slog.HandlerOptions{
        AddSource: true, // Add source file and line number to logs
        Level:     slog.LevelInfo,
    })

    log.Println("ConfigureServiceLogging::new_slog")
    logger := slog.New(handler)

    log.Println("ConfigureServiceLogging::setDefault")
    slog.SetDefault(logger)

    log.Println("ConfigureServiceLogging::end")
}

func main() {
    log.Println("Starting Application")
    ConfigureServiceLogging()
    log.Println("Stopping Application")
}

What did you see happen?

When I attempt to run this application it dies without a panic when attempting to SetDefault. Here is the output when I run ./main.exe from an interactive shell.

/ # ./main.exe                                                                                                                                   
2025/10/04 17:14:21 Starting Application
2025/10/04 17:14:21 ConfigureServiceLogging::start                                                                                               
2025/10/04 17:14:21 ConfigureServiceLogging::defineRotator
2025/10/04 17:14:21 ConfigureServiceLogging::defineHandler                                                                                       
2025/10/04 17:14:21 ConfigureServiceLogging::new_slog
2025/10/04 17:14:21 ConfigureServiceLogging::setDefault
/ # echo $?
0                                                                                          
/ # 

As you can clearly see, there are two log lines that never execute, nor would any other code. The application has an exit code of 0. Quite odd.

What did you expect to see?

I expected to see all log lines including the two missing ones to appear. Setting the default is supposed to allow for log.Printf or whatever function call is already there to continue to work but be brought into the slog configuration.

I even tried changing those last two log lines to slog.Info(...) and they continue to be missing from the logging output.

Comment From: seankhliao

That's what your lumberjack dependency does: it writes to a log file rather than printing to stderr.

/Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

Comment From: gabyhelp

Related Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: stunney

Well, this could very well be a bad codegen by Google Gemini!

Found another example on redit that showed the error of my ways.

in my main.go original commit, line 17 did not have a filename set. Okay so no file would be output from the logrotator. should still see output in stdout correct?

Wrong!

I did not have Stdout as a set handler using the MultiWriter construct as shown here:

    multiWriter := slog.NewJSONHandler(
        io.MultiWriter(os.Stdout, logRotator),
        &slog.HandlerOptions{
            AddSource: true,
            Level:     slog.LevelInfo,
        },
    )

I now have logging working. Not sure why this works properly on x86_64 but I'll take it where I can get it.

Comment From: seankhliao

I recommend reading the documentation for the libraries you are using instead of wasting maintainers' time. lumberjack does say where it puts logs if you don't give it a file name.