@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) {
}
}
java类org.apache.log4j.FileAppender的实例源码
Log4jLoggerAdapter.java 文件源码
项目:eds
阅读 21
收藏 0
点赞 0
评论 0
LogPageHandler.java 文件源码
项目:EatDubbo
阅读 21
收藏 0
点赞 0
评论 0
@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) {
}
}
Log4jLoggerAdapter.java 文件源码
项目:EatDubbo
阅读 18
收藏 0
点赞 0
评论 0
@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) {
}
}
EndPointHealthServiceImpl.java 文件源码
项目:endpoint-health
阅读 19
收藏 0
点赞 0
评论 0
private void setupLogging() {
LogManager.getLogManager().reset();
Logger.getRootLogger().getLoggerRepository().resetConfiguration();
final Logger rootLogger = Logger.getRootLogger();
final PatternLayout layout = new PatternLayout("%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n");
final Level level = endPointHealthConfiguration.logLevel();
final ConsoleAppender consoleAppender = new ConsoleAppender(layout, ConsoleAppender.SYSTEM_ERR);
consoleAppender.setThreshold(level);
consoleAppender.activateOptions();
final FileAppender fileAppender = new FileAppender();
fileAppender.setFile(endPointHealthConfiguration.logFile().getAbsolutePath());
fileAppender.setLayout(layout);
fileAppender.setThreshold(level);
fileAppender.setAppend(true);
fileAppender.setErrorHandler(new FallbackAppenderErrorHandler(rootLogger, fileAppender, consoleAppender));
rootLogger.addAppender(fileAppender);
fileAppender.activateOptions();
}
LogPageHandler.java 文件源码
项目:dubbo2
阅读 22
收藏 0
点赞 0
评论 0
@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) {
}
}
Log4jLoggerAdapter.java 文件源码
项目:dubbo2
阅读 25
收藏 0
点赞 0
评论 0
@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) {
}
}
DeliverNotifyBefore202Test.java 文件源码
项目:LightSIP
阅读 17
收藏 0
点赞 0
评论 0
public Notifier(int port) throws Exception {
this.port = port;
Properties properties = new Properties();
logger.addAppender(new FileAppender(new SimpleLayout(), "notifieroutputlog_" + port
+ ".txt"));
properties.setProperty("javax.sip.STACK_NAME", "notifier" + port);
// You need 16 for logging traces. 32 for debug + traces.
// Your code will limp at 32 but it is best for debugging.
properties.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
properties.setProperty("gov.nist.javax.sip.DEBUG_LOG", "notifierdebug_" + port
+ ".txt");
properties.setProperty("gov.nist.javax.sip.SERVER_LOG", "notifierlog_" + port
+ ".txt");
if(System.getProperty("enableNIO") != null && System.getProperty("enableNIO").equalsIgnoreCase("true")) {
logger.info("\nNIO Enabled\n");
properties.setProperty("gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY", NioMessageProcessorFactory.class.getName());
}
// Create SipStack object
sipStack = sipFactory.createSipStack(properties);
logger.info("sipStack = " + sipStack);
this.createProvider( );
this.udpProvider.addSipListener(this);
}
iBenchDriver.java 文件源码
项目:ibench
阅读 28
收藏 0
点赞 0
评论 0
private static void setUpExperimentalLogger(File pathF) throws IOException {
Logger.getRootLogger().removeAllAppenders();
log.removeAllAppenders();
PropertyConfigurator.configure("resource/log4jproperties.txt");
FileAppender resultAppender = new FileAppender(
new PatternLayout("%m"),
new File(pathF, "result.txt").toString(), false);
LevelRangeFilter infoFilter = new LevelRangeFilter();
infoFilter.setLevelMin(Level.INFO);
infoFilter.setLevelMax(Level.FATAL);
infoFilter.setAcceptOnMatch(true);
resultAppender.addFilter(infoFilter);
log.addAppender(resultAppender);
Logger.getLogger(iBench.class).addAppender(resultAppender);
}
iBenchDriver.java 文件源码
项目:ibench
阅读 23
收藏 0
点赞 0
评论 0
private static void setUpConfigLogger(File pathF, String configName) throws IOException {
Logger.getRootLogger().removeAllAppenders();
String nameSuffix = configName.replace(".txt", "");
PropertyConfigurator.configure("resource/log4jproperties.txt");
FileAppender logFileAppender = new FileAppender(
new PatternLayout("%-4r [%t] %-5p %c %x - %m%n"),
new File(pathF, "log_" + nameSuffix + ".txt").toString(), false);
Logger.getRootLogger().addAppender(logFileAppender);
if (opt.logToConsole)
Logger.getRootLogger().addAppender(new ConsoleAppender(
new PatternLayout("%-4r [%t] %-5p %c %x - %m%n")));
}
LogUtil.java 文件源码
项目:Log4Reports
阅读 24
收藏 0
点赞 0
评论 0
public LogUtil(LogConfig config, Object obj){
this.logConfig = config;
if(LogConfig.logType == 0){
report = new ExtentReports(config.getExtentLogPath(),false);
File configFile = new File(System.getProperty("user.dir") + "\\configs\\extent-config.xml");
if(configFile.exists()) {
report.loadConfig(configFile);
}
testLog = report.startTest(String.valueOf(obj));
}else{
logger = Logger.getLogger(String.valueOf(obj));
Layout layout = new PatternLayout("%d{yyyy-MM-dd HH:mm:ss} [%p] %c:%L �� %m%n");
try {
Appender appender = new FileAppender(layout, config.getLog4jPath());
logger.addAppender(appender);
} catch (IOException e) {
e.printStackTrace();
}
}
}
LogPageHandler.java 文件源码
项目:dubbox-hystrix
阅读 19
收藏 0
点赞 0
评论 0
@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) {
}
}
Log4jLoggerAdapter.java 文件源码
项目:dubbox-hystrix
阅读 16
收藏 0
点赞 0
评论 0
@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) {
}
}
LogPageHandler.java 文件源码
项目:dubbocloud
阅读 18
收藏 0
点赞 0
评论 0
@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) {
}
}
Log4jLoggerAdapter.java 文件源码
项目:dubbocloud
阅读 20
收藏 0
点赞 0
评论 0
@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) {
}
}
LogPageHandler.java 文件源码
项目:dubbos
阅读 15
收藏 0
点赞 0
评论 0
@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) {
}
}
Log4jLoggerAdapter.java 文件源码
项目:dubbos
阅读 19
收藏 0
点赞 0
评论 0
@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) {
}
}
SpiderApp.java 文件源码
项目:FunnySpider
阅读 20
收藏 0
点赞 0
评论 0
/**
* 设置日志配置
* @param level
* @param fileName
* @param append
* @return this
*/
public SpiderApp setLogerConfig(int level,String fileName,boolean append,String configFilename){
logMap.put("level", level);
logMap.put("fileName", fileName);
logMap.put("append",append);
logMap.put("configFilename",configFilename);
logger = Logger.getLogger(SpiderApp.class);
Level logLevel = getLogLevel(level);
try {
FileAppender appender = new FileAppender(new SimpleLayout(), fileName,append);
if(null == configFilename){
BasicConfigurator.configure();
}else{
PropertyConfigurator.configure(configFilename);
}
logger.addAppender(appender);
logger.setLevel(logLevel);
} catch (IOException e) {
e.printStackTrace(System.err);
}
return this;
}
BrokerRunner.java 文件源码
项目:TacTex
阅读 22
收藏 0
点赞 0
评论 0
private void reopenLogs(int counter)
{
Logger root = Logger.getRootLogger();
@SuppressWarnings("unchecked")
Enumeration<Appender> rootAppenders = root.getAllAppenders();
FileAppender logOutput = (FileAppender) rootAppenders.nextElement();
// assume there's only the one, and that it's a file appender
logOutput.setFile("log/broker" + counter + ".trace");
logOutput.activateOptions();
Logger state = Logger.getLogger("State");
@SuppressWarnings("unchecked")
Enumeration<Appender> stateAppenders = state.getAllAppenders();
FileAppender stateOutput = (FileAppender) stateAppenders.nextElement();
// assume there's only the one, and that it's a file appender
stateOutput.setFile("log/broker" + counter + ".state");
stateOutput.activateOptions();
}
LogPageHandler.java 文件源码
项目:dubbo-comments
阅读 17
收藏 0
点赞 0
评论 0
@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) {
}
}
Log4jLoggerAdapter.java 文件源码
项目:dubbo-comments
阅读 21
收藏 0
点赞 0
评论 0
@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) {
}
}
LogPageHandler.java 文件源码
项目:dubbox
阅读 21
收藏 0
点赞 0
评论 0
@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) {
}
}
Log4jLoggerAdapter.java 文件源码
项目:dubbox
阅读 36
收藏 0
点赞 0
评论 0
@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) {
}
}
LogPageHandler.java 文件源码
项目:dubbo
阅读 20
收藏 0
点赞 0
评论 0
@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) {
}
}
Log4jLoggerAdapter.java 文件源码
项目:dubbo
阅读 23
收藏 0
点赞 0
评论 0
@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) {
}
}
ZFXConf.java 文件源码
项目:zoofx
阅读 19
收藏 0
点赞 0
评论 0
public static void addAppender() {
FileAppender fa = new FileAppender();
fa.setName("FileLogger");
String logFile = getConfHome() + System.getProperty("file.separator") + "zoofx.log";
fa.setFile(logFile);
Enumeration<Appender> allAppenders = Logger.getRootLogger().getAllAppenders();
if(allAppenders.hasMoreElements()){
Appender appender = allAppenders.nextElement();
if(appender instanceof ConsoleAppender){
ConsoleAppender ca = (ConsoleAppender)appender;
fa.setLayout(ca.getLayout());
fa.setThreshold(ca.getThreshold());
}
fa.setAppend(true);
}
fa.activateOptions();
Logger.getRootLogger().addAppender(fa);
}
FreedomLogger.java 文件源码
项目:erp
阅读 19
收藏 0
点赞 0
评论 0
public static Logger getLogger(final Class<?> cl, final String initFile, final String property) {
Properties properties;
Logger c = null;
try {
ManagerIni mi = initFile != null ? ManagerIni.createManagerIniFile(initFile) : ManagerIni.createManagerIniParameter();
properties = mi.getSession("FreedomLogger");
c = Logger.getLogger(cl.getCanonicalName(), myFactory);
Layout layout = new PatternLayout(LAYOUT_DEFAULT);
c.addAppender(new FileAppender(layout, properties.get(property).toString(), true));
}
catch (Exception e) {
e.printStackTrace();
}
return c;
}
LogfileHandlerTest.java 文件源码
项目:bktail2
阅读 15
收藏 0
点赞 0
评论 0
@Before
public void setUp() throws Exception {
try {
Files.delete(Paths.get(FILEPATH));
} catch (Exception e) {
// TODO: handle exception
}
FileAppender fa = new FileAppender();
fa.setName("FileLogger");
fa.setFile(FILEPATH);
fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
fa.setThreshold(Level.DEBUG);
fa.setAppend(true);
fa.activateOptions();
//add appender to any Logger (here is root)
Logger.getRootLogger().addAppender(fa);
}
Log4jLoggerAdapter.java 文件源码
项目:light-task-scheduler
阅读 21
收藏 0
点赞 0
评论 0
@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) {
}
}
Util.java 文件源码
项目:caom2
阅读 20
收藏 0
点赞 0
评论 0
/**
* Initializes logging to a file.
* @param loggerNames the names of the loggers (usually names of packages
* or classes or ancestors of packages or classes). Can't be null.
* @param argMap command line arguments.
*/
public static synchronized void initFileLogging(String[] loggerNames, ArgumentMap argMap, String filename)
throws IOException
{
Level level = DEFAULT_FILE_LOGGING_LEVEL;
if (argMap.isSet(Argument.LOG_QUIET_SHORT) || argMap.isSet(Argument.LOG_QUIET)) level = Level.ERROR;
if (argMap.isSet(Argument.LOG_VERBOSE_SHORT) || argMap.isSet(Argument.LOG_VERBOSE)) level = Level.INFO;
if (argMap.isSet(Argument.LOG_DEBUG_SHORT) || argMap.isSet(Argument.DEBUG)) level = Level.DEBUG;
FileAppender fileAppender = new FileAppender(new PatternLayout(), filename);
boolean append = true;
Writer fileWriter = new FileWriter(filename, append);
for (String loggerName : loggerNames)
Log4jInit.setLevel(loggerName, level, fileWriter);
}
LogPageHandler.java 文件源码
项目:dubbo-learning
阅读 18
收藏 0
点赞 0
评论 0
@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) {
}
}