Log4j 2
  1. Log4j 2
  2. LOG4J2-765

Feature request: log warning to console if default configuration is used when missing log4j-core

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0, 2.0.1
    • Fix Version/s: 2.0.2
    • Component/s: API, Configurators, Core
    • Labels:
      None

      Description

      To summarize a recent twitter conversation:
      a user became very frustrated that Log4j2 did not log to the configured file, and gave up and moved on to JUL instead.

      After some questions it turned out that (probably) the problem was that they had log4j-api but not log4j-core in the classpath.

      We can dismiss this saying that users should read the documentation better, but users are in a hurry to get things done and I can easily see this happening to more people.

      In the above conversation, the user pointed out that very likely, if someone ends up with the default configuration (log ERROR level messages to the console), they made a mistake.

      The feature request is that log4j should help users by printing a message to the console that explains why the user ended up with the default configuration.

      • In case log4j-core not in the classpath: Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
      • In case no config file was found: No log4j2 configuration file found. Using default configuration: errors to the console.

      This last case is actually a frequent cause of questions on StackOverflow.

        Issue Links

          Activity

          Hide
          Remko Popma added a comment -

          Improved the warning:

          • mention that this message is generated by Log4j2
          • clarify to users how they can fix the problem.
            Fixed in revision 1616246.
          Show
          Remko Popma added a comment - Improved the warning: mention that this message is generated by Log4j2 clarify to users how they can fix the problem. Fixed in revision 1616246.
          Hide
          Remko Popma added a comment -

          LogManager already emits a warning if no implementation of the Log4j2 API can be found. I will use this Jira ticket to improve that warning message, and use LOG4J2-729 for the warning message when no configuration file is found.

          Show
          Remko Popma added a comment - LogManager already emits a warning if no implementation of the Log4j2 API can be found. I will use this Jira ticket to improve that warning message, and use LOG4J2-729 for the warning message when no configuration file is found.
          Hide
          Matt Sicker added a comment -

          An API+Core JAR would be neat since the API doesn't have any plugins (no shaded Log42jPlugins.dat file). In fact, I'd like an API+Core jar just for OSGi simplification at some point, but it's not necessary (or encouraged).

          Show
          Matt Sicker added a comment - An API+Core JAR would be neat since the API doesn't have any plugins (no shaded Log42jPlugins.dat file). In fact, I'd like an API+Core jar just for OSGi simplification at some point, but it's not necessary (or encouraged).
          Hide
          Gary Gregory added a comment -

          We could also provide an all-in-one jar and/or a api+core jar.

          Show
          Gary Gregory added a comment - We could also provide an all-in-one jar and/or a api+core jar.

            People

            • Assignee:
              Remko Popma
              Reporter:
              Remko Popma
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development