Question

I am annotating my function @Loggable jcabi annotation. The statement it logs is not complete, it trims the line and just prints .. for the truncated data. I want the entire line to be printed. Can this be done with this annotation.

@Loggable(Loggable.DEBUG)
public String load(URL url) {
  return url.openConnection().getContent();
}

Produces the following log

[DEBUG] #load('http://www.google.com'): returned "<html ..." in 23ms

Log4j.properties

# Root logger option
log4j.rootLogger=INFO, file, CONSOLE

# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=swami-plugin.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n


log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=com.jcabi.log.MulticolorLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%color{%-5p}] %c: %m%n
Was it helpful?

Solution

This is by design. @Loggable annotation outputs method parameter and result object by using their toString() methods of up to 100 characters. Mostly in order to keep log lines short enough to fit into syslog and similar systems.

Maybe it would be good to add an optional parameter to disable that trimming feature:

@Loggable(trim = false)
public String load(URL url) {

I would recommend to submit a request in github.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top