Skip to content

KLogger obscures location info #11

@dhutchis

Description

@dhutchis

I am using log4j with a patternlayout that includes class, method, and line number information. I expect log statements to print in the form below. This form holds when I manually set val logger: Logger = LoggerFactory.getLogger(this.javaClass).

INFO TEST_CONFIG.<init>(80) - test log

Instead, when I extend a companion object (or any singleton object) with object : KLogging(), the following unhelpful information prints

INFO KLogger.info(?) - test log

The code responsible for picking the location info is here in LocationInfo. The code sees that KLogger is the immediately logging class on the stack trace and uses KLogger for location info. It should instead use the class immediately below KLogger in the stack trace.

I'm not sure how to fix it, but there should be some hook in the log4j (ideally, slf4j) library that allows manipulating location info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions