Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta3
    • Fix Version/s: 2.0-beta4, 2.0-beta8
    • Component/s: None
    • Labels:
      None
    • Environment:

      Description

      I try to use the SocketAppender and get the following ERROR/NPE:

      2013-01-06 00:54:14,024 DEBUG Generated plugins in 0.000032000 seconds
      2013-01-06 00:54:14,044 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.PatternLayout for element PatternLayout with params(pattern="%d

      {HH:mm:ss.SSS}

      [%t] %-5level %logger

      {36} — %msg%n", Configuration(/Users/jhuxhorn/Documents/Projects/huxi/lilith/sandbox/log4j2-sandbox/build/resources/main/log4j2.xml), null, charset="null")
      2013-01-06 00:54:14,045 DEBUG Generated plugins in 0.000029000 seconds
      2013-01-06 00:54:14,049 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console with params(PatternLayout(%d{HH:mm:ss.SSS} [%t] %-5level %logger{36}

      — %msg%n), null, target="SYSTEM_OUT", name="Console", suppressExceptions="null")
      2013-01-06 00:54:14,049 DEBUG Calling createLayout on class org.apache.logging.log4j.core.layout.SerializedLayout for element SerializedLayout
      2013-01-06 00:54:14,052 DEBUG Calling createAppender on class org.apache.logging.log4j.core.appender.SocketAppender for element Socket with params(host="localhost", port="4560", protocol="null", reconnectionDelay="null", name="Socket", immediateFlush="null", suppressExceptions="null", SerializedLayout(org.apache.logging.log4j.core.layout.SerializedLayout@5cc4211b), null)
      2013-01-06 00:54:14,054 ERROR Unable to invoke method createAppender in class org.apache.logging.log4j.core.appender.SocketAppender for element Socket java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.apache.logging.log4j.core.config.BaseConfiguration.createPluginObject(BaseConfiguration.java:711)
      at org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:477)
      at org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:469)
      at org.apache.logging.log4j.core.config.BaseConfiguration.doConfigure(BaseConfiguration.java:156)
      at org.apache.logging.log4j.core.config.BaseConfiguration.start(BaseConfiguration.java:114)
      at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:251)
      at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:267)
      at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:134)
      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
      at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:30)
      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:165)
      at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:174)
      at de.huxhorn.lilith.sandbox.Log4j2Sandbox.main(Log4j2Sandbox.java:43)
      Caused by: java.lang.NullPointerException
      at org.apache.logging.log4j.core.appender.SocketAppender.createSocketManager(SocketAppender.java:95)
      at org.apache.logging.log4j.core.appender.SocketAppender.createAppender(SocketAppender.java:86)
      ... 17 more

      2013-01-06 00:54:14,056 ERROR Null object returned for Socket in appenders

      My configuration looks like this:
      <?xml version="1.0" encoding="UTF-8"?>
      <configuration status="debug">
      <appenders>
      <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d

      {HH:mm:ss.SSS}

      [%t] %-5level %logger

      {36}

      — %msg%n"/>
      </Console>
      <Socket name="Socket" host="localhost" port="4560">
      <SerializedLayout />
      </Socket>
      </appenders>
      <loggers>
      <root level="all">
      <appender-ref ref="Console"/>
      <appender-ref ref="Socket"/>
      </root>
      </loggers>
      </configuration>

      1. log4j2-139.diff
        1 kB
        Gary Gregory

        Activity

        Hide
        Joern Huxhorn added a comment -

        Confirmed.

        Show
        Joern Huxhorn added a comment - Confirmed.
        Hide
        Ralph Goers added a comment -

        Fixed in revision 1491348. Please verify and close.

        Show
        Ralph Goers added a comment - Fixed in revision 1491348. Please verify and close.
        Hide
        Joern Huxhorn added a comment -

        beta7 introduced a regression that causes the following NPE in the absence of a protocol attribute:

        2013-06-09 16:31:30,634 ERROR Unable to invoke method createAppender in class org.apache.logging.log4j.core.appender.SocketAppender for element Socket java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.logging.log4j.core.config.BaseConfiguration.createPluginObject(BaseConfiguration.java:765)
        at org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:529)
        at org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:521)
        at org.apache.logging.log4j.core.config.BaseConfiguration.doConfigure(BaseConfiguration.java:170)
        at org.apache.logging.log4j.core.config.BaseConfiguration.start(BaseConfiguration.java:123)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:331)
        at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:370)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:149)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:85)
        at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:34)
        at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:360)
        at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:319)
        at de.huxhorn.lilith.sandbox.Log4j2Sandbox.main(Log4j2Sandbox.java:43)
        Caused by: java.lang.NullPointerException
        at org.apache.logging.log4j.core.appender.SocketAppender.createAppender(SocketAppender.java:120)
        ... 17 more

        Show
        Joern Huxhorn added a comment - beta7 introduced a regression that causes the following NPE in the absence of a protocol attribute: 2013-06-09 16:31:30,634 ERROR Unable to invoke method createAppender in class org.apache.logging.log4j.core.appender.SocketAppender for element Socket java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.logging.log4j.core.config.BaseConfiguration.createPluginObject(BaseConfiguration.java:765) at org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:529) at org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:521) at org.apache.logging.log4j.core.config.BaseConfiguration.doConfigure(BaseConfiguration.java:170) at org.apache.logging.log4j.core.config.BaseConfiguration.start(BaseConfiguration.java:123) at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:331) at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:370) at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:149) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:85) at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:34) at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:360) at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:319) at de.huxhorn.lilith.sandbox.Log4j2Sandbox.main(Log4j2Sandbox.java:43) Caused by: java.lang.NullPointerException at org.apache.logging.log4j.core.appender.SocketAppender.createAppender(SocketAppender.java:120) ... 17 more
        Hide
        Joern Huxhorn added a comment -

        Confirmed.

        Show
        Joern Huxhorn added a comment - Confirmed.
        Hide
        Ralph Goers added a comment -

        Fixed in revision 1429632. The protocol will default to TCP for the SocketAppender and UDP for the SyslogAppender.

        Show
        Ralph Goers added a comment - Fixed in revision 1429632. The protocol will default to TCP for the SocketAppender and UDP for the SyslogAppender.
        Hide
        Gary Gregory added a comment -

        How about making TCP the default? See patch.

        Show
        Gary Gregory added a comment - How about making TCP the default? See patch.
        Hide
        Joern Huxhorn added a comment - - edited

        Found the solution: the appender was missing a protocol attribute.
        <?xml version="1.0" encoding="UTF-8"?>
        <configuration status="debug">
        <appenders>
        <Console name="Console" target="SYSTEM_OUT">
        <PatternLayout pattern="%d

        {HH:mm:ss.SSS}

        [%t] %-5level %logger

        {36}

        — %msg%n"/>
        </Console>
        <Socket name="Socket" host="localhost" port="4560" protocol="TCP">
        <SerializedLayout />
        </Socket>
        </appenders>
        <loggers>
        <root level="all">
        <appender-ref ref="Console"/>
        <appender-ref ref="Socket"/>
        </root>
        </loggers>
        </configuration>
        works as expected.

        Show
        Joern Huxhorn added a comment - - edited Found the solution: the appender was missing a protocol attribute. <?xml version="1.0" encoding="UTF-8"?> <configuration status="debug"> <appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d {HH:mm:ss.SSS} [%t] %-5level %logger {36} — %msg%n"/> </Console> <Socket name="Socket" host="localhost" port="4560" protocol="TCP"> <SerializedLayout /> </Socket> </appenders> <loggers> <root level="all"> <appender-ref ref="Console"/> <appender-ref ref="Socket"/> </root> </loggers> </configuration> works as expected.

          People

          • Assignee:
            Ralph Goers
            Reporter:
            Joern Huxhorn
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development