Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging using @Loggable jcabi annotations trims the logs

Tags:

java

log4j

jcabi

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
like image 331
Nandish A Avatar asked Nov 12 '22 10:11

Nandish A


1 Answers

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.

like image 80
yegor256 Avatar answered Nov 15 '22 07:11

yegor256