Skip to content

Log messages below LogLevel(-1_000) are ignored, even when a custom task-local logger is used #52234

Open
@DilumAluthge

Description

@DilumAluthge

MWE:

using Logging: Logging, @logmsg, LogLevel, with_logger, ConsoleLogger

with_logger(ConsoleLogger(LogLevel(-5_000))) do
    @logmsg LogLevel(-3_000) "hello world"
end

I would expect this to print the log message, because I am using a custom task-local logger, and I expected my custom logger to override any global behavior. However, this MWE will result in no logs being printed.


Workaround

Here's a workaround:

using Logging: Logging, @logmsg, LogLevel, with_logger, ConsoleLogger

+ Logging.disable_logging(Logging.BelowMinLevel)

with_logger(ConsoleLogger(LogLevel(-5_000))) do
    @logmsg LogLevel(-3_000) "hello world"
end

With the workaround, the log message is printed:

┌ LogLevel(-3000): hello world
└ @ Main REPL[3]:2

I still think this is a bug though. IMO, when using a custom logger (e.g. with with_logger() do ...), the min_level of the custom logger should be the only thing that matters, and the global settings should not prevent log messages from being printed.


Related issues

Related: #34037

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorloggingThe logging framework

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions