⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logconfig.java

📁 struts+hibernate3的源程序
💻 JAVA
字号:

package com.helpsoft.util.log;

/**
 * Value object with log settings
 * @author caoguangxin- www.relationinfo.com

 */
public class LogConfig {

   /** the logfile to log to */
   private String logFile = "finalist%g.log";

   /** append to the logfile */
   private boolean append = true;

   /** maximum number of logfiles to create */
   private int maxBackupIndex = 1;

   /** maxfilesize for each created logfile */
   private int maxFileSize = 50;

   /** the number of packages to show for a class */
   private int showNumberOfLastPackages = 0;

   /** the datepattern to log */
   private String datePattern = "yyyy-MM-dd HH:mm:ss,SSS";

   /** the messagespearator */
   private String messageSeparator = "-";

   /** the loglevel for logging certain messages */
   private String logLevel = "INFO";


   /**
    * Constrcutor for making a LogConfig
    * All settings for a appender
    * @param logFile the name of the logfile, default finalist%g.log
    * @param append default true
    * @param maxBackupIndex the number of files to create, must be greater than 0, default 1
    * @param maxFileSize the size of a log file in megabytes, must be greater than 0, default 50
    * @param showNumberOfLastPackages the number of pacakges of a class to show, cannot be negative, default 0
    * @param datePattern the date to log, default yyyy-MM-dd HH:mm:ss,SSS
    * @param messageSeparator default -
    * @param logLevel default INFO
    */
   public LogConfig(String logFile,
         boolean append,
         int maxBackupIndex,
         int maxFileSize,
         int showNumberOfLastPackages,
         String datePattern,
         String messageSeparator,
         String logLevel) {
      if ((logFile != null) && (!logFile.equals(""))) {
         this.logFile = logFile;
      }
      this.append = append;
      if (maxBackupIndex > 0) {
         this.maxBackupIndex = maxBackupIndex;
      }
      if (maxFileSize > 0) {
         this.maxFileSize = maxFileSize;
      }
      if (showNumberOfLastPackages > -1) {
         this.showNumberOfLastPackages = showNumberOfLastPackages;
      }
      if ((datePattern != null) && (!datePattern.equals(""))) {
         this.datePattern = datePattern;
      }
      if ((messageSeparator != null) && (!messageSeparator.equals(""))) {
         this.messageSeparator = messageSeparator;
      }
      if ((logLevel != null) && (!logLevel.equals(""))) {
         this.logLevel = logLevel;
      }
   }


   /**
    * Get the name of the logfile
    * @return String, the name of the log file
    */
   public String getLogFile() {
      return this.logFile;
   }


   /**
    * Check to see if the logfile is appendable
    * @return boolean, logfile is appendable
    */
   public boolean isAppendable() {
      return this.append;
   }


   /**
    * Get the maxBackupIndex
    * @return int, the maxBackupIndex
    */
   public int getMaxBackupIndex() {
      return this.maxBackupIndex;
   }


   /**
    * Get the maxFileSize
    * @return int, maxFileSize
    */
   public int getMaxFileSize() {
      return this.maxFileSize;
   }


   /**
    * Get the showNumberOfLastPackages
    * @return int, the showNumberOfLastPackages
    */
   public int getShowNumberOfLastPackages() {
      return this.showNumberOfLastPackages;
   }


   /**
    * Get the datePattern
    * @return String, the datePattern
    */
   public String getDatePattern() {
      return this.datePattern;
   }


   /**
    * Get the messageSeparator
    * @return String, the messageSeparator
    */
   public String getMessageSeparator() {
      return this.messageSeparator;
   }


   /**
    * Get the logLevel
    * @return String, the logLevel
    */
   public String getLogLevel() {
      return this.logLevel;
   }


   /**
    * returning the string with all values
    * @return String, all values as a String
    */
   public String toString() {
      return "[logFile=" + this.logFile + "]" +
            ", [append=" + this.append + "]" +
            ", [maxBackupIndex=" + this.maxBackupIndex + "]" +
            ", [maxFileSize=" + this.maxFileSize + "]" +
            ", [showNumberOfLastPackages=" + this.showNumberOfLastPackages + "]" +
            ", [datePattern=" + this.datePattern + "]" +
            ", [messageSeparator=" + this.messageSeparator + "]" +
            ", [logLevel=" + this.logLevel + "]";
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -