FileDocCategorySizeDatePackage
LoggerTag.javaAPI DocExample1611Mon May 12 11:52:00 BST 2003com.jspservletcookbook

LoggerTag

public class LoggerTag extends BodyTagSupport

Fields Summary
private Logger
log
private String
configFile
private String
level
private static final String[]
LEVELS
Constructors Summary
Methods Summary
private booleancontains(java.lang.String str)

     
         for (int i = 0; i < LEVELS.length; i++){
         
             if(LEVELS[i].equals(str))
                 return true;
         }
         return false;
     
public intdoEndTag()


  if (configFile != null)
     PropertyConfigurator.configure(pageContext.getServletContext().getRealPath("/") + "WEB-INF/classes/" + configFile);

  level = level.toLowerCase();
  if (! contains(level))
        throw new JspException("The value given for the level attribute is invalid.");

  log = Logger.getLogger(LoggerTag.class);
  String message = getBodyContent().getString().trim();
  Method method = null;

  try{
            
            method = log.getClass().getMethod(level,new Class[]{ Object.class });
            method.invoke(log,new String[]{message});

 } catch (Exception e){}
    
 return EVAL_PAGE;
     
public voidrelease()

 
     
         log = null;
         configFile = null;
         level = null;
     
public voidsetConfigFile(java.lang.String fileName)


   

this.configFile = fileName;

public voidsetLevel(java.lang.String level)


this.level = level;