We are creating one instance of logger by using
private static Logger = Logger.getClass("ClassName.class");
Each action class has a logger. This worked fine in our test environment. However, it is giving occasional thread hungs in WAS 7 in Production environment. As per IBM server analysts, the log file is getting locked while waiting for a DB update.
Following is what I have in log4j.xml.
<appender name="logger1" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="/logs1/logFile.log" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<param name="Threshold" value="DEBUG" />
<param name="Append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p (%F:%L) - %m%n" />
</layout>
</appender>
Could someone help ? Is there any advantage if I remove static ? Is there any advantage if I use SL4j LoggerFactory to get logger ?
EDIT : Relevant Point : The log4j.xml is shared between 2 applications. The applications are 2 WAR files within 1 EAR file. The log4j.xml has 2 appenders. Each application removes the other appender within the code.
No.
Logger.getClasswould still return the same instance. Therefore this doesn’t change anything with respect to locking in log4j.No (at least not for the problem you are facing). Locking is done in log4j. SLF4J is just a facade that would still delegate to log4j (unless you replace log4j by something else).