jscherman
jscherman

Reputation: 6189

log4j is not logging entire message when its too long

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?

Upvotes: 0

Views: 1389

Answers (1)

Brian Agnew
Brian Agnew

Reputation: 272347

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.

Upvotes: 1

Related Questions