Servername in SocketAppender

Hi, I want to use the SocketAppender to collect log messages from more than one application server. It general it works fine, but I'm missing the servername or IP address of the server who sent the LoggingEvent. That means I need a layout like this: %date %servername %m%n In the documentation, I see a SocketAppender property called IncludeCallerData. But in the example it only prints %file and %line. What is the best practise to add the name/IP of the server which sent the logging event to the remote SimpleSocketServer? Best regards, Ingo

Hello Ingo, Properties of the logger context are part of each logging event sent to the SocketAppender. You can set a context property 'k' to value 'v' as follows: LoggerContext lc = (LoggerContext) org.slf4j.LoggerFactory.getILoggerFactory(); lc.putProperty("k", "v"); You can have the value of property 'k' printed using the "%property" conversion word. In PatternLayout set the pattern to for example "%property{k} ... - %m%n" As of logback 0.9.19, the HOSTNAME property is defined automatically. Also note that the name of the context can be retrieved with the %contextName or %cn conversion words. You can set the name of the context either programmatically as lc.setName("mickey"); or in the configuration file: <configuration> <contextName>mickey</contextName> ... </configuration> HTH, On 04/03/2010 10:17 AM, Ingo Siebert wrote:
Hi,
I want to use the SocketAppender to collect log messages from more than one application server.
It general it works fine, but I'm missing the servername or IP address of the server who sent the LoggingEvent. That means I need a layout like this: %date %servername %m%n
In the documentation, I see a SocketAppender property called IncludeCallerData. But in the example it only prints %file and %line.
What is the best practise to add the name/IP of the server which sent the logging event to the remote SimpleSocketServer? Best regards,
Ingo

Hi, I think there is another problem with SocketAppenders. Features like MDC (%X{username}) aren't working. Please correct me if I'm wrong. Ingo Am 04.03.2010 10:17, schrieb Ingo Siebert:
Hi,
I want to use the SocketAppender to collect log messages from more than one application server.
It general it works fine, but I'm missing the servername or IP address of the server who sent the LoggingEvent. That means I need a layout like this: %date %servername %m%n
In the documentation, I see a SocketAppender property called IncludeCallerData. But in the example it only prints %file and %line.
What is the best practise to add the name/IP of the server which sent the logging event to the remote SimpleSocketServer? Best regards,
Ingo _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
participants (2)
-
Ceki Gülcü
-
Ingo Siebert