当前位置: 首页>>代码示例>>Java>>正文


Java FileAppender.getFile方法代码示例

本文整理汇总了Java中org.apache.log4j.FileAppender.getFile方法的典型用法代码示例。如果您正苦于以下问题:Java FileAppender.getFile方法的具体用法?Java FileAppender.getFile怎么用?Java FileAppender.getFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.log4j.FileAppender的用法示例。


在下文中一共展示了FileAppender.getFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Log4jLoggerAdapter

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Log4jLoggerAdapter() {
	try {
		org.apache.log4j.Logger logger = LogManager.getRootLogger();
           if (logger != null) {
               Enumeration<Appender> appenders = logger.getAllAppenders();
               if (appenders != null) {
                   while (appenders.hasMoreElements()) {
                       Appender appender = appenders.nextElement();
                       if (appender instanceof FileAppender) {
                           FileAppender fileAppender = (FileAppender)appender;
                           String filename = fileAppender.getFile();
                           file = new File(filename);
                           break;
                       }
                   }
               }
           }
       } catch (Throwable t) {
       }
}
 
开发者ID:eXcellme,项目名称:eds,代码行数:22,代码来源:Log4jLoggerAdapter.java

示例2: LogPageHandler

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public LogPageHandler() {
    try {
		org.apache.log4j.Logger logger = LogManager.getRootLogger();
        if (logger != null) {
            Enumeration<Appender> appenders = logger.getAllAppenders();
            if (appenders != null) {
                while (appenders.hasMoreElements()) {
                    Appender appender = appenders.nextElement();
                    if (appender instanceof FileAppender) {
                        FileAppender fileAppender = (FileAppender)appender;
                        String filename = fileAppender.getFile();
                        file = new File(filename);
                        break;
                    }
                }
            }
        }
    } catch (Throwable t) {
    }
   }
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:22,代码来源:LogPageHandler.java

示例3: getRootLoggerDirectory

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
/**
 * Get the root logger file location under which the failed log messages will be written.
 *
 * Since this class is used in Hooks which run within JVMs of other components like Hive,
 * we want to write the failed messages file under the same location as where logs from
 * the host component are saved. This method attempts to get such a location from the
 * root logger's appenders. It will work only if at least one of the appenders is a {@link FileAppender}
 *
 * @return directory under which host component's logs are stored.
 */
private String getRootLoggerDirectory() {
    String rootLoggerDirectory = null;
    org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger();

    Enumeration allAppenders = rootLogger.getAllAppenders();
    if (allAppenders != null) {
        while (allAppenders.hasMoreElements()) {
            Appender appender = (Appender) allAppenders.nextElement();
            if (appender instanceof FileAppender) {
                FileAppender fileAppender = (FileAppender) appender;
                String rootLoggerFile = fileAppender.getFile();
                rootLoggerDirectory = new File(rootLoggerFile).getParent();
                break;
            }
        }
    }
    return rootLoggerDirectory;
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:29,代码来源:FailedMessagesLogger.java

示例4: addHostToFilename

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
private void addHostToFilename(FileAppender fileApp) {
    String hostID = Math.abs(UniqueID.getCurrentVMID().hashCode() % 100000) + "-" +
                    ProActiveInet.getInstance().getHostname();
    String fileName = fileApp.getFile();
    File filePath = new File(fileName);
    String hostFileName;
    String name = filePath.getName();
    String pathToFile = filePath.getParent();
    int point = name.indexOf('.');
    if (point == -1) {
        hostFileName = fileName + "-" + hostID;
    } else {
        String extension = name.substring(point + 1);
        String nameNoExtension = name.substring(0, point);
        hostFileName = (pathToFile != null ? pathToFile : "") + File.separator + nameNoExtension + "-" + hostID +
                       "." + extension;
    }
    System.out.println("New output file:" + hostFileName);
    fileApp.setFile(hostFileName);
    fileApp.activateOptions();
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:22,代码来源:ActiveActor.java

示例5: Log4jLoggerAdapter

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Log4jLoggerAdapter(){
    try {
        org.apache.log4j.Logger logger = LogManager.getRootLogger();
        if (logger != null) {
            Enumeration<Appender> appenders = logger.getAllAppenders();
            if (appenders != null) {
                while (appenders.hasMoreElements()) {
                    Appender appender = appenders.nextElement();
                    if (appender instanceof FileAppender) {
                        FileAppender fileAppender = (FileAppender) appender;
                        String filename = fileAppender.getFile();
                        file = new File(filename);
                        break;
                    }
                }
            }
        }
    } catch (Throwable t) {
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:22,代码来源:Log4jLoggerAdapter.java

示例6: LogPageHandler

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public LogPageHandler() {
    try {
        org.apache.log4j.Logger logger = LogManager.getRootLogger();
        if (logger != null) {
            Enumeration<Appender> appenders = logger.getAllAppenders();
            if (appenders != null) {
                while (appenders.hasMoreElements()) {
                    Appender appender = appenders.nextElement();
                    if (appender instanceof FileAppender) {
                        FileAppender fileAppender = (FileAppender) appender;
                        String filename = fileAppender.getFile();
                        file = new File(filename);
                        break;
                    }
                }
            }
        }
    } catch (Throwable t) {
    }
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:22,代码来源:LogPageHandler.java

示例7: Log4jLoggerAdapter

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Log4jLoggerAdapter() {
    try {
        org.apache.log4j.Logger logger = LogManager.getRootLogger();
        if (logger != null) {
            Enumeration<Appender> appenders = logger.getAllAppenders();
            if (appenders != null) {
                while (appenders.hasMoreElements()) {
                    Appender appender = appenders.nextElement();
                    if (appender instanceof FileAppender) {
                        FileAppender fileAppender = (FileAppender) appender;
                        String filename = fileAppender.getFile();
                        file = new File(filename);
                        break;
                    }
                }
            }
        }
    } catch (Throwable t) {
    }
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:22,代码来源:Log4jLoggerAdapter.java

示例8: SystemLogPage

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
public SystemLogPage() {
	super();
	
	WebMarkupContainer cssContainer = new WebMarkupContainer("cssPath");
       cssContainer.add(new AttributeModifier("href", ThemesManager.getInstance().getThemeRelativePathCss()));
       add(cssContainer);
	
	FileAppender appender = (FileAppender) LogManager.getRootLogger().getAppender("FILE");
	File logFile = new File(appender.getFile());
	
	String content;
	try {
		content = FileUtils.readFileToString(logFile);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		content = e.toString();
	}
	
	add(new Label("size", FileUtils.byteCountToDisplaySize(logFile.length())));
	add(new Label("lastModified", new Date(logFile.lastModified()).toString()));
	add(new MultiLineLabel("log", content));
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:24,代码来源:SystemLogPage.java

示例9: getActiveLogFiles

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
public static Set<File> getActiveLogFiles() throws IOException {
  Set<File> ret = Sets.newHashSet();
  Appender a;
  @SuppressWarnings("unchecked")
  Enumeration<Appender> e = Logger.getRootLogger().getAllAppenders();
  while (e.hasMoreElements()) {
    a = e.nextElement();
    if (a instanceof FileAppender) {
      FileAppender fa = (FileAppender) a;
      String filename = fa.getFile();
      ret.add(new File(filename));
    }
  }
  return ret;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:LogMonitoring.java

示例10: setFileAppender

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
private static void setFileAppender(FileAppender bizFileAppender, String logName) {
    FileAppender fileAppender = getFileAppender(Logger.getLogger(logName));
    String bizLogDir = new File(bizFileAppender.getFile()).getParent();

    File newLogFile = new File(bizLogDir, fileAppender.getFile());

    fileAppender.setFile(newLogFile.getAbsolutePath());
    fileAppender.activateOptions(); // 很重要,否则原有日志内容会被清空
    log.warn("成功为" + logName + "添加Appender. 输出路径:" + newLogFile.getAbsolutePath());
}
 
开发者ID:lysu,项目名称:diamond,代码行数:11,代码来源:LoggerInit.java

示例11: getLogFileInformation

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
public static LogFileInformation getLogFileInformation(Logger logger)
{
  if (logger == null) {
    logger = LogManager.getRootLogger();
  }
  FileAppender fileAppender = getFileAppender(logger);
  if (fileAppender != null) {
    File logFile = new File(fileAppender.getFile());
    LogFileInformation logFileInfo = new LogFileInformation(fileAppender.getFile(), logFile.length());
    return logFileInfo;
  }
  return null;
}
 
开发者ID:apache,项目名称:apex-core,代码行数:14,代码来源:LoggerUtil.java

示例12: setFileAppender

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
private static void setFileAppender(FileAppender bizFileAppender, String logName) {
    FileAppender fileAppender = getFileAppender(Logger.getLogger(logName));
    String bizLogDir = new File(bizFileAppender.getFile()).getParent();

    File newLogFile = new File(bizLogDir, fileAppender.getFile());

    fileAppender.setFile(newLogFile.getAbsolutePath());
    fileAppender.activateOptions(); // 很重要,否则原有日志内容会被清空
    logger.warn("成功为" + logName + "添加Appender. 输出路径:" + newLogFile.getAbsolutePath());
}
 
开发者ID:xushaomin,项目名称:diamond-v2.1.1,代码行数:11,代码来源:LoggerInit.java

示例13: getLogFile

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
/**
 * returns the first configured {@link FileAppender} or <code>null</code>.
 * 
 * @return
 */
public static String getLogFile() {
	Enumeration<?> enu = Logger.getRootLogger().getAllAppenders();
	while (enu.hasMoreElements()) {
		Object o = enu.nextElement();
		if (o instanceof FileAppender) {
			FileAppender fa = (FileAppender) o;
			return fa.getFile();
		}
	}
	return null;
}
 
开发者ID:bh4017,项目名称:mobac,代码行数:17,代码来源:Logging.java

示例14: getAppenderPath

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
private String getAppenderPath(FileAppender fileAppender) {
    String path = null;
    try {
        String fileName = fileAppender.getFile();
        if (fileName != null && !fileName.isEmpty()) {
            path = new File(fileName).getCanonicalPath();
        }
    } catch (IOException e) {
        LogLog.error("Unable to retrieve appender's file name", e);
    }
    return path;
}
 
开发者ID:szhem,项目名称:log4j-json-layout,代码行数:13,代码来源:LogStashJsonLayout.java

示例15: setFileAppender

import org.apache.log4j.FileAppender; //导入方法依赖的package包/类
private static void setFileAppender(FileAppender bizFileAppender, String logName) {
    FileAppender fileAppender = getFileAppender(Logger.getLogger(logName));
    String bizLogDir = new File(bizFileAppender.getFile()).getParent();

    File newLogFile = new File(bizLogDir, fileAppender.getFile());

    fileAppender.setFile(newLogFile.getAbsolutePath());
    fileAppender.activateOptions(); // ����Ҫ������ԭ����־���ݻᱻ���
    log.warn("�ɹ�Ϊ" + logName + "���Appender. ���·��:" + newLogFile.getAbsolutePath());
}
 
开发者ID:weijiahao001,项目名称:tb_diamond,代码行数:11,代码来源:LoggerInit.java


注:本文中的org.apache.log4j.FileAppender.getFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。