Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2432

Make `namedLogger` more discoverable

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • Kotlin 1.0.0
    • Kotlin 1.0.0
    • Kotlin API
    • None

    Description

      Currently, when instantiating a logger by name instead of by object (such as when not in the scope of an object e.g. a top-level function), one has to use `namedLogger(name)`. This is not very discoverable – the user will simply get a "not found" error on `logger`, with no hints or IDE feedback on what to do or why `logger` cannot be found.

      A better approach is to rename the `namedLogger` function to simply `logger`. When it is called within an Object without a parameter, the extension function will be used. When it is called with a parameter, whether inside or out, the named logger will be created. This is discoverable as the user's IDE will prompt for the missing `name` parameter when used from a top-level function, as in this scope only the named function is valid.

      Attachments

        Activity

          People

            mattsicker Matt Sicker
            rocketraman Raman Gupta
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: