/** * 添加日志服务 * * @param filePath */ public void addFileAppender(String filePath) { int index = filePath.LastIndexOf(FILESEPARATOR); if (index < 0) { filePath = FILESEPARATOR + "log" + FILESEPARATOR + filePath; } FileAppenderConfig fileAppenderConfig = new FileAppenderConfig(); fileAppenderConfig.m_logFile = filePath; fileAppenderConfig.m_name = "FileAppender"; fileAppenderConfig.m_type = "FileAppender"; fileAppenderConfig.m_datePattern = "yyyy-MM-dd HH:mm:ss"; fileAppenderConfig.m_logType = 1; FileAppender appender = new FileAppender(fileAppenderConfig); appender.m_id = getNewAppenderId(); addAppender(appender); }
/** * 指定配置文件的位置 * * @param configPath */ public FileAppender(String configPath) { m_fileAppenderConfig = new FileAppenderConfig(); m_fileAppenderConfig.loadConfig(configPath); checkDirectory(m_fileAppenderConfig.m_logFile); }
/** * 指定一个配置文件FileAppenderConfig * * @param fileAppenderConfig */ public FileAppender(FileAppenderConfig fileAppenderConfig) { m_fileAppenderConfig = fileAppenderConfig; checkDirectory(m_fileAppenderConfig.m_logFile); }