Child Loggers
In Logry, every logger instance is lightweight and modular.
You can freely create child loggers that inherit settings from their parent — while overriding only what you need.
Creating a Child Logger
You can use the .child()
method to create a scoped or customized logger:
const logger = logry({ id: "main-app", level: "info" });
const authLogger = logger.child({
level: "debug", // override log level
scope: "auth", // add a scope
context: { userType: "admin" }, // inject default context
});
Child Logger Inheritance
Child loggers inherit settings by merging properties differently depending on their type:
-
scope
: Appended
["main"]
+"auth"
→["main", "auth"]
-
context
: Merged, child overrides
{ app: "main", user: "guest" }
+{ user: "admin" }
→{ app: "main", user: "admin" }
-
formatterConfig
/normalizerConfig
:
Shallow merged per platform (node
,browser
), with child taking precedence
⭐ This keeps child loggers flexible and contextual, without needing to re-specify everything.