aspose file tools*
The moose likes Other Open Source Projects and the fly likes SimpleSocketServer error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "SimpleSocketServer error" Watch "SimpleSocketServer error" New topic
Author

SimpleSocketServer error

Nick Verma
Greenhorn

Joined: Oct 27, 2004
Posts: 9
I am trying to run an example of log4j SimpleSocketServer to accept logging from remote clients. The properties file that I am using is:

log4j.rootLogger=DEBUG, x
log4j.appender.x=org.apache.log4j.net.SocketAppender
log4j.appender.x.RemoteHost=localhost
log4j.appender.x.Port=4445
log4j.appender.x.LocationInfo=true
log4j.appender.x.layout=org.apache.log4j.PatternLayout
log4j.appender.x.layout.ConversionPattern=[%d{MMM dd HH:mm:ss}] %-5p (%F:%L) - %m%n

While running I get the following error.

C:\logging-log4j-1.2.9\examples\chapter1>java org.apache.log4j.net.SimpleSocketS
erver 4445 log4j.properties
log4j:ERROR Could not connect to remote log4j server at [localhost]. We will try
again later.
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.apache.log4j.net.SocketAppender.connect(SocketAppender.java:195)
at org.apache.log4j.net.SocketAppender.activateOptions(SocketAppender.ja
va:152)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:2
47)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.j
ava:123)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.j
ava:87)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigura
tor.java:645)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigura
tor.java:603)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyC
onfigurator.java:500)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurato
r.java:406)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurato
r.java:307)
at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.
java:315)
at org.apache.log4j.net.SimpleSocketServer.init(SimpleSocketServer.java:
84)
at org.apache.log4j.net.SimpleSocketServer.main(SimpleSocketServer.java:
44)


Please advise where is the problem.
Thanks
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
That looks like the properties file the clients should use, not the server. The server configuration would more likely include something like a RollingFileAppender.

For example, here's a socket server's properties file from Ceki G�lc�'s The complete log4j manual (highly recommended):


# -------------------------------------------------------------------
# This config file is intended to be used by a SocketServer that logs
# events received from various clients on the console and to a file
# which is rolled over when appropriate. The interesting point to note
# is that it a configuration file like any other.
-------------------------------------------------------------------

log4j.debug=true

log4j.rootLogger=debug, CONSOLE, ROLL

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p [%t] %c - %m%n

log4j.appender.ROLL=org.apache.log4j.RollingFileAppender
log4j.appender.ROLL.File=rolling.log
log4j.appender.ROLL.MaxFileSize=10KB
log4j.appender.ROLL.MaxBackupIndex=2
log4j.appender.ROLL.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLL.layout.ConversionPattern=%d %-5p %c - %m%n

[ February 23, 2005: Message edited by: Carol Enderlin ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SimpleSocketServer error