0

I have a problem with log4j. It's automatically initiated by some classes I cannot touch (related to AWS, I think) and it results in a really low performance (12MB image download from 5 minutes to 20 seconds without it). My code and problem:

Servlet reading from Amazon S3 so slow

My intention is to stop log4j while downloading a file and enable it afterwards, but I cannot find a way to do so. The only way I have been able to stop it, without being able to resume the process afterwards, is:

Logger.shutdown();

But I really need the logger to work in other situations. I've tried changing the log4j.properties file

log4j.appender.file=org.apache.log4j.RollingFileAppender

#Log local
log4j.appender.file.File=Rs.log

log4j.appender.file.append=true
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=5
log4j.appender.FILE.datePattern='.' yyyy-MM-dd
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d (%5p) %-5l - <%m>%n
log4j.rootLogger=debug, file 

and change debug to off and this code from Disabling Log4J Output in Java:

List<Logger> loggers = Collections<Logger>list(LogManager.getCurrentLoggers());
loggers.add(LogManager.getRootLogger());
for ( Logger logger : loggers ) {
    logger.setLevel(Level.OFF);
}

Nothing works, not even to shut it down.

The logger itself while downloading images looks like this:

2016-08-25 08:26:35,735 (DEBUG) org.apache.http.impl.conn.Wire.wire(Wire.java:72) - < << "[0xb1] [0x96]a[0x4][0xa5] [0x82][0x17](R[0xc2][0x1][0x87][\n]">

but again, I can't access Wire.java to take a look.

Community
  • 1
  • 1
Sergio Tx
  • 3,706
  • 1
  • 16
  • 29
  • It seems to me, that the logging comes from apache http client, not Amazon WS. Can you add more details how you changed log4j config? – Betlista Aug 25 '16 at 06:42
  • Possible duplicate of [Disable HttpClient logging](http://stackoverflow.com/questions/4915414/disable-httpclient-logging) – Betlista Aug 25 '16 at 06:43
  • can you show your log4j.properties – kuhajeyan Aug 25 '16 at 06:47
  • added log4j.properties. I will take a look at your link now, @Betlista – Sergio Tx Aug 25 '16 at 06:49
  • After a lot of tests I've found that it's not considering the config file at all. And AWS has some info about Wire logging: https://docs.aws.amazon.com/java-sdk/latest/developer-guide/java-dg-logging.html – Sergio Tx Aug 26 '16 at 07:34

0 Answers0