Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to not throw exceptions to server.log in java
    text
    copied!<p>In my application I am using <code>log4j</code> and have a <code>my_system.log</code> where all the messages should be thrown. Problem I have is that when an error happens it is also showing up in <code>server.log</code> (I don't want this to happen). </p> <pre><code>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(); } </code></pre> <p>As you can see, I am catching the exceptions because I want to log it in <code>my_system.log</code> but because I want the execution to halt (since the error happened) I throw the error again.</p> <p>I believe because I am throwing it, it is showing in server.log. </p> <p>How can I avoid this ?</p> <p>UPDATE:</p> <p>Following are my appenders:</p> <pre><code>&lt;appender name="myAppender" class="org.apache.log4j.AsyncAppender"&gt; &lt;appender-ref ref="myFile" /&gt; &lt;/appender&gt; &lt;appender name="myFile" class="org.apache.log4j.DailyRollingFileAppender"&gt; &lt;param name="File" value="../systems/my/log/my_system.log" /&gt; &lt;param name="Append" value="true" /&gt; &lt;param name="DatePattern" value="'.'yyyy-MM-dd" /&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;param name="ConversionPattern" value="[%d{dd/MMM/yyyy:HH:mm:ss.SSS}]~[%-5p]~[%c:%M]~[%m]%n" /&gt; &lt;/layout&gt; &lt;filter class="org.apache.log4j.varia.LevelRangeFilter"&gt; &lt;param name="LevelMin" value="TRACE#com.org.common.logging.HUDLogLevel" /&gt; &lt;param name="LevelMax" value="FATAL" /&gt; &lt;/filter&gt; &lt;/appender&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload