return ConfigWebUtil.getLogAndSource(config,strLogger,logLevel);
}
return new LogAndSourceImpl(LogConsole.getInstance(config,logLevel),strLogger);
}
private static LogAndSource getLogAndSource(Config config, String strLogger, int logLevel) {
if(strLogger==null) return new LogAndSourceImpl(LogConsole.getInstance(config,logLevel),"");
// File
strLogger=translateOldPath(strLogger);
Resource file=ConfigWebUtil.getFile(config, config.getConfigDir(),strLogger, ResourceUtil.TYPE_FILE);
if(file!=null && ResourceUtil.canRW(file)) {
try {
return new LogAndSourceImpl(new LogResource(file,logLevel,config.getResourceCharset()),strLogger);
} catch (IOException e) {
SystemOut.printDate(config.getErrWriter(),e.getMessage());
}
}
if(file==null)SystemOut.printDate(config.getErrWriter(),"can't create logger from file ["+strLogger+"], invalid path");
else SystemOut.printDate(config.getErrWriter(),"can't create logger from file ["+strLogger+"], no write access");
return new LogAndSourceImpl(LogConsole.getInstance(config,logLevel),strLogger);
}