Luc14860 / jwebsocket

Automatically exported from code.google.com/p/jwebsocket
0 stars 0 forks source link

Custom log4j configuration error #176

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm using jwebsocket server 1.0 beta 6 version, with a custom log4j.xml 
configuration (attached), containing two appenders "jwebsocketToken" (root 
appender) and "jwebsocket" (for the "org.jwebsocket.server.TokenServer" 
category).

With this configuration, when starting a command-line server, I get a hundred 
of "log4j:ERROR Attempted to append to closed appender named [developmentLog]" 
messages in the console, even if I have no "developmentLog" appender in my 
configuration, and the log files in the logs directory are empty.

If I start a command-line server with the "-Dlog4j.debug" JVM variable, the 
output is:

log4j: Trying to find [log4j.xml] using context classloader 
sun.misc.Launcher$AppClassLoader@12360be0.
log4j: Using URL 
[jar:file:/home/ngavalda/dev/jWebSocket-1.0/libs/jWebSocketServer-1.0.jar!/log4j
.xml] for automatic log4j configuration.
[...]
log4j: Adding appender named [developmentLog] to category [root].
log4j: Adding appender named [jmxLog] to category [root].
[...]
log4j: Adding appender named [jwebsocket] to category [root].

It seems that the log4j.xml file embedded in jWebSocketServer-1.0.jar is loaded 
first, then my custom conf/log4j.xml, appending to the first configuration 
instead of replacing it.

To make the logging system properly, I have to add a reset="true" attribute to 
the "log4j:configuration" XML root in my conf/log4j.xml file.

It seems that calling LogManager.resetConfiguration() before calling 
DOMConfigurator.configure() (in the JWebSocketConfig class) would resolve the 
problem too, without forcing users to add the reset="true" attribute to the 
custom conf.

Original issue reported on code.google.com by nicolas....@gmail.com on 23 Apr 2012 at 4:08

Attachments:

GoogleCodeExporter commented 8 years ago
Why jWebsocket fixed log4j.xml file to be in conf folder while it can read it 
from class path as other APIs and as well as applications do.We need to maitain 
two log4j.xml files because of this. JWebSocketConfig.initForWebApp trying to 
read log4j.xml file from conf dir.

Original comment by pavanvus...@gmail.com on 27 Feb 2013 at 12:32