Show page source of LogLevelDebugJava #13700

== Log Debug java ==

---

Debugで出力するLogは基本的に以下の情報を出力する。

 * コンストラクタ時のメッセージ
 * 関数の入通知と引数のダンプ
 * 関数の出通知と返値のダンプ
 * servletの場合には受け取ったPOSTデータの値

    以下必要な情報は随時追加

---

 またdebugログを出力する場合は'''必ず現状のログレベルがdebugであることを確認し、出力するデータを作成する'''こと。

---

example. jsp

{{{ code java
<%@ page language="java" contentType="text/html; charset=ASCII" %>
<%@ page import="org.apache.log4j*" %>
<%@ page import="org.ultramonkey.l7.model.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html"; charset=ASCII">
<title>sample</title>
<body>
<%
  Logger logger = Logger.getLogger( LogCategorySet.JSPCategory );
  if( logger.isDebugEnable() ){
    logger.debug( "sample.jsp start" );
  }
  SampleClass sampleClass = SampleClass.getInstance();
  if( null == sampleClass ){
    logger.error( "SampleClass.getInstance() is NULL!" );
  }
%>

hello world!
<%
  if( logger.isDebugEnable() ){
    logger.debug( "sample.jsp exit" );
  }
%>
</body>
</html>
}}}

example class
{{{ code java
package org.ultramonkey.l7;
import org.apache.log4j.*;

public class Sample{
  Logger logger = null;
  public Sample(){
    logger = Logger.getInstance( LogCategorySet.SampleCategory );
    if( logger.isDebugEnable() ){
      logger.debug( "class Sample created." );
    }
  }
  public String foo(Sample sample, String string) throws Exception {
    // debug log (in method)
    if( logger.isDebugEnable() ){
      StringBuffer buf = new StringBuffer();
      buf.append("Sample::foo(Sample sample, String string) throws Exception in ");
      buf.append("sample=" + sample + ", ");
      buf.append("string=" + string);
      logger.debug(buf.toString());
    }

    if( null != sample ){
      logger.error( "in sample value is null. check configure" );
    }

    // debug log (out method)
    if( logger.isDebugEnable() ){
      StringBuffer buf = new StringBuffer();
      buf.append("Sample::foo(Sample sample, String string) throws Exception out ");
      buf.append("return=" + sample.toString + string);
      logger.debug(buf.toString());
    }

    return sample.toString + string;
  }
}


}}}