码迷,mamicode.com
首页 > 其他好文 > 详细

日志框架实现实时改动,实时生效,详细框架思路(2)

时间:2017-05-28 17:23:17      阅读:174      评论:0      收藏:0      [点我收藏+]

标签: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 = ",";
    
    

日志框架实现实时改动,实时生效,详细框架思路(2)

标签:gconf   pen   art   write   java   prefix   puts   logs   stream   

原文地址:http://www.cnblogs.com/lxjshuju/p/6916006.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!