You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Kohinoor Lal Verma (EHS)" <Ko...@ehs.ericsson.se> on 2002/11/01 09:45:37 UTC

RE: Missing location thru SocketServer (was: Interesting Problem)

Hi Gautam,

This has helped me a lot. I had posted a similar question a month back (on
30/9/02 with subject :SocketAppender help required).
Today I've got my answer. Thanx a ton to you.

Rgds
Kohinoor



-----------------------------

Kohinoor Lal Verma 
Senior Systems Engineer 
Ericsson Mobile Commerce Platform
New Delhi, India 

-----Original Message-----
From: gautamsatpathy [mailto:gautamsatpathy@yahoo.com]
Sent: Thursday, October 31, 2002 11:48 PM
To: log4j-user@jakarta.apache.org
Subject: Re: Missing location thru SocketServer (was: Interesting
Problem)


Hello Thomas,

Found the problem. It is in SocketAppender. The SocketAppender uses 
an option called "LocationInfo" which defaults to "false". As a 
result, the LoggingEvent object written to the socket does not 
contain any location information. That is, it does not contain a 
reference to a "LocationInfo" object. Hence, no location information.

Add  the following to your log4j configuration for the client (the 
classes logging to the ServerSocket) :

log4j.appender.socketserver.LocationInfo=true

When you are done, your configuration file should have the following:

log4j.appender.socketserver = org.apache.log4j.net.SocketAppender
log4j.appender.socketserver.RemoteHost = 127.0.0.1
log4j.appender.socketserver.Port = 8889
log4j.appender.socketserver.LocationInfo=true

This is not mentioned anywhere in the documentation (at least I 
couldn't locate anything). The JavaDoc for SocketAppender does 
mention the following:

"getLocationInfo() 
          Returns value of the LocationInfo option
          
setLocationInfo(boolean locationInfo) 
          The LocationInfo option takes a boolean value. "

Hope this helps.

Regards,

Gautam Satpathy

--- In Log4J@y..., "Thomas Saxtoft" <t....@s...> wrote:
> Hi Gautam
> 
> Finally I got that far. Now I get location information on both 
client and server. Thank you Gautam.
> But I still has got a problem. I don't get any location info thru 
my Log4j SocketServer. 
> I write to a log file on the client, the server and the socket 
server using the same ConversionPattern:
> 
> log4j.appender.R.layout.ConversionPattern=[slf5s.start]%d{DATE}
[slf5s.DATE]%n\
> %p[slf5s.PRIORITY]%n%x[slf5s.NDC]%n%t[slf5s.THREAD]%n\
> %c[slf5s.CATEGORY]%n%l[slf5s.LOCATION]%n%m[slf5s.MESSAGE]%n%n
> 
> But when I read the log file on the SocketServer in does not 
contain any location info.
> I am able to find the exact same log statement on both 
client/server and SocketServer, but on the SocketServer location info 
is missing!
> 
> I initialize the SocketServer like this:
> log4j.appender.socketserver = org.apache.log4j.net.SocketAppender
> log4j.appender.socketserver.RemoteHost = 127.0.0.1
> log4j.appender.socketserver.Port = 8889
> 
> 
> Thomas Saxtoft
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@j...>
> For additional commands, e-mail: <ma...@j...>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>