In my application I am using log4j
and have a my_system.log
where all the messages should be thrown. Problem I have is that when an error happens it is also showing up in server.log
(I don't want this to happen).
public String getAccessFlag (String userId, String participantCode, String roleId) {
HashMap parmMap = new HashMap();
parmMap.put("userId", userId.toUpperCase());
parmMap.put("roleId", roleId);
log.info(parmMap);
try {
getSqlMapClientOltp().queryForList("auth.getAccess", parmMap);
} catch (SQLException ex) {
log.error(ex, ex);
throw new RuntimeException (ex);
}
List result = (List)parmMap.get("Result0");
return ((String)(((HashMap) result.get(0)).get("accessVoucher"))).trim();
}
As you can see, I am catching the exceptions because I want to log it in my_system.log
but because I want the execution to halt (since the error happened) I throw the error again.
I believe because I am throwing it, it is showing in server.log.
How can I avoid this ?
UPDATE:
Following are my appenders:
<appender name="myAppender" class="org.apache.log4j.AsyncAppender">
<appender-ref ref="myFile" />
</appender>
<appender name="myFile" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="../systems/my/log/my_system.log" />
<param name="Append" value="true" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{dd/MMM/yyyy:HH:mm:ss.SSS}]~[%-5p]~[%c:%M]~[%m]%n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="TRACE#com.org.common.logging.HUDLogLevel" />
<param name="LevelMax" value="FATAL" />
</filter>
</appender>