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.