/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import com.alphacsp.common.log.Log; import org.apache.log4j.Category; import org.apache.log4j.FileAppender; import org.apache.log4j.AppenderSkeleton; import java.lang.reflect.Field; import java.util.Enumeration; public class FileAppenderManipulation { try { Category category = getCategory(log); final FileAppender fileAppender = (FileAppender) locateAppender(category, appenderName); fileAppender.setFile(filename); fileAppender.activateOptions(); e.printStackTrace(); e.printStackTrace(); } } do { while (appenders.hasMoreElements()) { AppenderSkeleton appenderSkeleton = (AppenderSkeleton) appenders.nextElement(); if (appenderSkeleton.getName().equals(name)) { return appenderSkeleton; } } } while ((category = category.getParent()) != null); } field.setAccessible(true); Category category = (Category) field.get(log); return category; } }