0

i am using org.slf4j:slf4j-log4j12:1.7.12. Here is my log4j.properties:

log4j.rootCategory=INFO, CONSOLE, UDP

# Console appender
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss, SSS} [%X{uow}-%X{requestId}] [%15.15t] %-5p %30.30c l%-3L %x - %m%n

# UDP appender
log4j.appender.UDP=com.mybusiness.framework.logging.log4j.appender.UDPExceptionSocketAppender
log4j.appender.UDP.layout=org.apache.log4j.PatternLayout
log4j.appender.UDP.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss, SSS} [%X{uow}-%X{requestId}] [%15.15t] %-5p %30.30c l%-3L %x - %m%n
log4j.appender.UDP.destinationAddress=log.ic.mybusiness.it
log4j.appender.UDP.destinationPort=32211

When i want to log a long message, i have different outputs on each appender. e.g. if the message has 17000 chars, from the console i get 14000 chars and from udp i get 8000 chars. I think that the problem here could be related with some max length per line config, am i right? Still, i couldn't find that specific property.

Do you have any idea about this?

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
jscherman
  • 5,839
  • 14
  • 46
  • 88

1 Answers1

1

I suspect the issue is with the datagram (UDP packet) size.

In theory you can have a UDP packet size of approx 65,000 bytes, but you need to take into account the MTU (maximum transmission unit) size of your transport, and that will likely give you a much smaller packet.

If you want reliable and lossless communication, then UDP is not a solution, and I would advise a TCP-based mechanism.

More info with this question.

Community
  • 1
  • 1
Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
  • So if i understood it right, the only way to fix the problem would be changing the packet size to something bigger? And why the console appender is not printing it right also? couldn't be something related to properly log4j configurations? maybe it has some default value that is restricting content length (i am talking from my total ignorance at the subject). Thanks for your response – jscherman Dec 11 '15 at 17:25