/** * 构造函数 * * @param fileAppenderConfig */ public SeparateDirAppender(RollingFileAppenderConfig fileAppenderConfig) { m_fileAppenderConfig = fileAppenderConfig; m_baseLogFileName = m_fileAppenderConfig.m_logFile; checkDirectory(m_baseLogFileName); CalculateLogFileSize(); }
/** * 构造函数 * * @param fileAppenderConfig */ public RollingFileAppender(RollingFileAppenderConfig fileAppenderConfig) { m_fileAppenderConfig = fileAppenderConfig; m_baseLogFileName = m_fileAppenderConfig.m_logFile; checkDirectory(m_baseLogFileName); calculateLogFileSize(); initExistingLog(); }
/** * 构造函数 * * @param configPath */ public SeparateDirAppender(String configPath) { m_fileAppenderConfig = new RollingFileAppenderConfig(); m_fileAppenderConfig.loadConfig(configPath); m_baseLogFileName = m_fileAppenderConfig.m_logFile; checkDirectory(m_baseLogFileName); CalculateLogFileSize(); }
/** * 构造函数 * * @param configPath */ public RollingFileAppender(String configPath) { m_fileAppenderConfig = new RollingFileAppenderConfig(); m_fileAppenderConfig.loadConfig(configPath); m_baseLogFileName = m_fileAppenderConfig.m_logFile; checkDirectory(m_baseLogFileName); calculateLogFileSize(); initExistingLog(); }
/** * 添加日志服务 * * @param filePath */ public void addSeparateDirAppender(String filePath) { int index = filePath.LastIndexOf(FILESEPARATOR); if (index < 0) { filePath = String.Format("{0}log{1}{2}{3}{4}", FILESEPARATOR, FILESEPARATOR, getNowDate("yyyyMMDD"), FILESEPARATOR, filePath); } RollingFileAppenderConfig fileAppenderConfig = new RollingFileAppenderConfig(); fileAppenderConfig.m_logFile = filePath; fileAppenderConfig.m_name = "SeparateDirAppender"; fileAppenderConfig.m_type = "SeparateDirAppender"; fileAppenderConfig.m_datePattern = "yyyy-MM-dd HH:mm:ss"; fileAppenderConfig.m_logType = 1; fileAppenderConfig.m_maxFileSize = "200kb"; fileAppenderConfig.m_maxSizeRollBackups = 50; SeparateDirAppender appender = new SeparateDirAppender(fileAppenderConfig); appender.m_id = getNewAppenderId(); addAppender(appender); }
/** * 添加日志服务 * * @param filePath */ public void addRollingFileAppender(String filePath) { int index = filePath.LastIndexOf(FILESEPARATOR); if (index < 0) { filePath = FILESEPARATOR + "log" + FILESEPARATOR + filePath; } RollingFileAppenderConfig fileAppenderConfig = new RollingFileAppenderConfig(); fileAppenderConfig.m_logFile = filePath; fileAppenderConfig.m_name = "RollingFileAppender"; fileAppenderConfig.m_type = "RollingFileAppender"; fileAppenderConfig.m_datePattern = "yyyy-MM-dd HH:mm:ss"; fileAppenderConfig.m_logType = 1; fileAppenderConfig.m_maxFileSize = "200kb"; fileAppenderConfig.m_maxSizeRollBackups = 50; RollingFileAppender appender = new RollingFileAppender(fileAppenderConfig); appender.m_id = getNewAppenderId(); addAppender(appender); }