You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Joern Huxhorn (JIRA)" <ji...@apache.org> on 2013/01/06 02:52:12 UTC

[jira] [Commented] (LOG4J2-139) NPE while using SocketAppender

    [ https://issues.apache.org/jira/browse/LOG4J2-139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13545271#comment-13545271 ] 

Joern Huxhorn commented on LOG4J2-139:
--------------------------------------

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">
			<!-- https://issues.apache.org/jira/browse/LOG4J2-139 -->
			<SerializedLayout />
		</Socket>
	</appenders>
	<loggers>
		<root level="all">
			<appender-ref ref="Console"/>
			<appender-ref ref="Socket"/>
		</root>
	</loggers>
</configuration>
works as expected.
                
> NPE while using SocketAppender
> ------------------------------
>
>                 Key: LOG4J2-139
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-139
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.0-beta3
>         Environment: ------------------------------------------------------------
> Gradle 1.3
> ------------------------------------------------------------
> Gradle build time: Dienstag, 20. November 2012 11:37 Uhr UTC
> Groovy: 1.8.6
> Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
> Ivy: 2.2.0
> JVM: 1.7.0_10 (Oracle Corporation 23.6-b04)
> OS: Mac OS X 10.8.2 x86_64
>            Reporter: Joern Huxhorn
>
> 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>

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org