标签:gconf pen art write java prefix puts logs stream
上次的文章中提到了:编写工具类,工具类中实现。依据日志管理表。创建log4j.properties配置文件。
工具类的详细实现例如以下:
package com.work.log.service.util;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Properties;
import org.apache.log4j.Logger;
import com.work.log.bean.LogConfigBean;
public class BuildLog4jPropertiesFile {
private Logger LOG = Logger.getLogger(BuildLog4jPropertiesFile.class);
private static String WEB_INF_PATH = BuildLog4jPropertiesFile.class.getResource("/").getPath();
private static String LOG4J_BACK_PROP = "log4j_back.properties";
private static final String ENTER_CODE = "\r\n";
private static String LOG4J_PROPERTIES_NAME = "log4j.properties";
private static String LOG_PATH = WEB_INF_PATH+"../../../../logs/";
private static final String LAYOUT_PATTERN_VALUE = "%-d{yyyyMMdd HH:mm:ss} [%l] - [ %p ] %m%n";
private static final String LOG4J_APPEND_KEY_PREFIX = "log4j.appender.";
private static final String FILE_KEY_PREFIX = ".File";
private static final String DATE_PATTERN_KEY = ".DatePattern";
private static final String DATE_PATTERN_VALUE = "‘.‘yyyyMMdd";
private static final String MAX_FILE_SIZE_KEY_PREFIX = ".MaxFileSize";
private static final String MAX_BACKUP_INDEX = ".MaxBackupIndex";
private static final String LAYOUT_KEY_PREFIX = ".layout";
private static final String LAYOUT_VALUE = "org.apache.log4j.PatternLayout";
private static final String LAYOUT_PATTERN_KEY = ".layout.ConversionPattern";
private static final String LOG4J_KEY_PREFIX = "log4j.logger.";
private static final String FILE_APPEND_VALUE = "org.apache.log4j.DailyRollingFileAppender";
private static final String COMMA = ",";
标签:gconf pen art write java prefix puts logs stream
原文地址:http://www.cnblogs.com/lxjshuju/p/6916006.html