jsrosetta

Basics

Logging

How ad-hoc timestamped console.log in Node.js compares to Go's log/log-slog, Rust's tracing crate, Swift's Foundation, and Java's System.Logger.

Minimum versions
Node.js ≥ 12.20Go ≥ 1.21Rust ≥ 1.65Swift ≥ 4.0Java ≥ 25
Verified on
Node.js 24.12.0Go 1.27.1Rust 1.98.1Swift 6.2.4Java 25.0.4.1

Node.js code is an ES module: save it as .mjs or set "type": "module" in package.json.

Node.js has no bundled logger: if you want a timestamp or JSON output, you assemble it yourself with console.log. Go has the log package (which prepends a date and time to every line), and since Go 1.21 there's also log/slog for structured, leveled logging. Rust has no logger in std at all — you reach for an external crate (tracing). Swift also has no bundled structured logger (Apple's os.Logger writes to the system log, Apple-only, not to stdout). Java has System.Logger built into java.base since Java 9.

Timestamped logging and JSON logging

console.log((new Date()).toISOString(), 'hello world')
 
// structured (JSON) output — Node.js has no bundled structured logger, so
// logging a plain object as JSON is the common baseline
console.log(JSON.stringify({ level: 'info', msg: 'hello world', time: new Date().toISOString() }))
# Node.js
2026-09-27T12:55:39.470Z hello world
{"level":"info","msg":"hello world","time":"2026-09-27T12:55:39.471Z"}
 
# Go
2026/09/27 19:55:40 hello world
2026/09/27 19:55:40 INFO hello world count=1
 
# Rust
2026-09-27T18:03:27.401099Z  INFO logging: hello world
{"timestamp":"2026-09-27T18:03:27.401360Z","level":"INFO","fields":{"message":"hello world","count":1},"target":"logging"}
 
# Swift
2026-09-27T18:04:28Z hello world
{"level":"info","msg":"hello world","time":"2026-09-27T18:04:28Z"}
 
# Java
Sep 28, 2026 1:05:00 AM Main main
INFO: hello world
{"level":"info","msg":"hello world","time":"2026-09-27T18:05:00.428159Z"}

(timestamps will differ on every run)

Reference: github.com/miguelmota/golang-for-nodejs-developers#logging