本文整理了Java中freemarker.log.Logger
类的一些代码示例,展示了Logger
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger
类的具体详情如下:
包路径:freemarker.log.Logger
类名称:Logger
[英]Delegates logger creation to an actual logging library. By default it looks for logger libraries in this order (in FreeMarker 2.3.x): Log4J, Avalon LogKit, JUL (i.e., java.util.logging). Prior to FreeMarker 2.4, SLF4J and Apache Commons Logging aren't searched automatically due to backward compatibility constraints. But if you have log4j-over-slf4j properly installed (means, you have no real Log4j in your class path, and SLF4J has a backing implementation like logback-classic), then FreeMarker will use SLF4J directly instead of Log4j (since FreeMarker 2.3.22).
If the auto detection sequence describet above doesn't give you the result that you want, see #SYSTEM_PROPERTY_NAME_LOGGER_LIBRARY.
[中]将记录器创建委托给实际的日志库。默认情况下,它按以下顺序查找记录器库(在FreeMarker 2.3.x中):Log4J、Avalon LogKit、JUL(即java.util.logging)。在FreeMarker 2.4之前,由于向后兼容性限制,SLF4J和Apache Commons日志不会自动搜索。但是,如果您正确安装了log4j-over-slf4j(这意味着,您的类路径中没有真正的log4j,并且slf4j具有类似logback classic的支持实现),那么FreeMarker将直接使用slf4j而不是log4j(自FreeMarker 2.3.22以来)。
如果上面的自动检测序列描述没有给出您想要的结果,请参阅#系统(u属性)名称(u记录器)库。
代码示例来源:origin: org.freemarker/freemarker
private static Class getClass(String className) {
try {
return ClassUtil.forName(className);
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Couldn't load class " + className, e);
}
return null;
}
}
代码示例来源:origin: org.freemarker/freemarker
private static ExpressionFactory tryExpressionFactoryImplementation(String packagePrefix) {
String className = packagePrefix + ".el.ExpressionFactoryImpl";
try {
Class cl = ClassUtil.forName(className);
if (ExpressionFactory.class.isAssignableFrom(cl)) {
LOG.info("Using " + className + " as implementation of " +
ExpressionFactory.class.getName());
return (ExpressionFactory) cl.newInstance();
}
LOG.warn("Class " + className + " does not implement " +
ExpressionFactory.class.getName());
} catch (ClassNotFoundException e) {
} catch (Exception e) {
LOG.error("Failed to instantiate " + className, e);
}
return null;
}
代码示例来源:origin: org.freemarker/freemarker
private void onSameNameClassesDetected(String className) {
// TODO: This behavior should be pluggable, as in environments where
// some classes are often reloaded or multiple versions of the
// same class is normal (OSGi), this will drop the cache contents
// too often.
if (LOG.isInfoEnabled()) {
LOG.info(
"Detected multiple classes with the same name, \"" + className +
"\". Assuming it was a class-reloading. Clearing class introspection " +
"caches to release old data.");
}
forcedClearCache();
}
代码示例来源:origin: org.freemarker/freemarker
public void report(TemplateException te, Environment env) {
String message = "Error executing FreeMarker template part in the #attempt block";
if (!logAsWarn) {
LOG.error(message, te);
} else {
LOG.warn(message, te);
}
}
代码示例来源:origin: org.freemarker/freemarker
TldParserForTaglibBuilding(ObjectWrapper wrapper) {
if (wrapper instanceof BeansWrapper) {
beansWrapper = (BeansWrapper) wrapper;
} else {
beansWrapper = null;
if (LOG.isWarnEnabled()) {
LOG.warn("Custom EL functions won't be loaded because "
+ (wrapper == null
? "no ObjectWrapper was specified for the TaglibFactory "
+ "(via TaglibFactory.setObjectWrapper(...), exists since 2.3.22)"
: "the ObjectWrapper wasn't instance of " + BeansWrapper.class.getName())
+ ".");
}
}
}
代码示例来源:origin: org.uberfire/uberfire-workbench-processors
protected AbstractErrorAbsorbingProcessor() {
try {
freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE);
} catch (ClassNotFoundException e) {
rememberedInitError = e;
}
}
代码示例来源:origin: org.freemarker/freemarker
public void stop() {
this.stop = true;
if (serverSocket != null) {
try {
serverSocket.close();
} catch (IOException e) {
LOG.error("Unable to close server socket.", e);
}
}
}
}
代码示例来源:origin: org.freemarker/freemarker
private void addTldLocationsFromFileDirectory(final File dir) throws IOException, SAXException {
if (dir.isDirectory()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Scanning for *.tld-s in File directory: " + StringUtil.jQuoteNoXSS(dir));
}
File[] tldFiles = dir.listFiles(new FilenameFilter() {
public boolean accept(File urlAsFile, String name) {
return isTldFileNameIgnoreCase(name);
}
});
if (tldFiles == null) {
throw new IOException("Can't list this directory for some reason: " + dir);
}
for (int i = 0; i < tldFiles.length; i++) {
final File file = tldFiles[i];
addTldLocationFromTld(new FileTldLocation(file));
}
} else {
LOG.warn("Skipped scanning for *.tld for non-existent directory: " + StringUtil.jQuoteNoXSS(dir));
}
}
代码示例来源:origin: org.freemarker/freemarker
private static void logInLogger(boolean error, String message, Throwable exception) {
boolean canUseRealLogger;
synchronized (Logger.class) {
canUseRealLogger = loggerFactory != null && !(loggerFactory instanceof _NullLoggerFactory);
}
if (canUseRealLogger) {
try {
final Logger logger = Logger.getLogger("freemarker.logger");
if (error) {
logger.error(message);
} else {
logger.warn(message);
}
} catch (Throwable e) {
canUseRealLogger = false;
}
}
if (!canUseRealLogger) {
System.err.println((error ? "ERROR" : "WARN") + " "
+ LoggerFactory.class.getName() + ": " + message);
if (exception != null) {
System.err.println("\tException: " + tryToString(exception));
while (exception.getCause() != null) {
exception = exception.getCause();
System.err.println("\tCaused by: " + tryToString(exception));
}
}
}
}
代码示例来源:origin: org.freemarker/freemarker
if (getLogTemplateExceptions() && LOG.isErrorEnabled()
LOG.error("Error executing FreeMarker template", templateException);
代码示例来源:origin: org.freemarker/freemarker
/**
* Convenience method. Tells the system to use Xalan for XPath queries.
* @throws Exception if the Xalan XPath classes are not present.
*/
static public void useXalanXPathSupport() throws Exception {
Class.forName("org.apache.xpath.XPath");
Class c = Class.forName("freemarker.ext.dom.XalanXPathSupport");
synchronized (STATIC_LOCK) {
xpathSupportClass = c;
}
LOG.debug("Using Xalan classes for XPath support");
}
代码示例来源:origin: org.freemarker/freemarker
LOG.debug("Looking for TLD locations in TLD-s specified in cfg.classpathTlds");
in = tldLocation.getInputStream();
} catch (IOException e) {
if (LOG.isWarnEnabled()) {
LOG.warn("Ignored classpath TLD location " + StringUtil.jQuoteNoXSS(tldResourcePath)
+ " because of error", e);
代码示例来源:origin: org.freemarker/freemarker
LOG.info("Failed to check if finetuneMethodAppearance is overidden in " + thisClass.getName()
+ "; acting like if it was, but this way it won't utilize the shared class introspection "
+ "cache.",
LOG.warn("Overriding " + BeansWrapper.class.getName() + ".finetuneMethodAppearance is deprecated "
+ "and will be banned sometimes in the future. Use setMethodAppearanceFineTuner instead.");
ftmaDeprecationWarnLogged = true;
代码示例来源:origin: org.freemarker/freemarker
/**
* Logs flag warning for a limited number of times. This is used to prevent
* log flooding.
*/
static void logFlagWarning(String message) {
if (!flagWarningsEnabled) return;
int cnt;
synchronized (flagWarningsCntSync) {
cnt = flagWarningsCnt;
if (cnt < MAX_FLAG_WARNINGS_LOGGED) {
flagWarningsCnt++;
} else {
flagWarningsEnabled = false;
return;
}
}
message += " This will be an error in some later FreeMarker version!";
if (cnt + 1 == MAX_FLAG_WARNINGS_LOGGED) {
message += " [Will not log more regular expression flag problems until restart!]";
}
LOG.warn(message);
}
代码示例来源:origin: org.freemarker/freemarker
if (wrapper.isStrict()) {
throw new InvalidPropertyException("No such bean property: " + key);
} else if (LOG.isDebugEnabled()) {
logNoSuchKey(key, classInfo);
代码示例来源:origin: org.freemarker/com.springsource.freemarker
logger.info("Overwriting value [" + obj + "] for " +
" key '" + name + "' with [" + method +
"] in static model for " + clazz.getName());
代码示例来源:origin: kiegroup/appformer
protected AbstractErrorAbsorbingProcessor() {
try {
freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE);
} catch (ClassNotFoundException e) {
rememberedInitError = e;
}
}
代码示例来源:origin: org.freemarker/freemarker
private ServletException newServletExceptionWithFreeMarkerLogging(String message, Throwable cause) throws ServletException {
if (cause instanceof TemplateException) {
// For backward compatibility, we log into the same category as Environment did when
// log_template_exceptions was true.
LOG_RT.error(message, cause);
} else {
LOG.error(message, cause);
}
ServletException e = new ServletException(message, cause);
try {
// Prior to Servlet 2.5, the cause exception wasn't set by the above constructor.
// If we are on 2.5+ then this will throw an exception as the cause was already set.
e.initCause(cause);
} catch (Exception ex) {
// Ignored; see above
}
throw e;
}
代码示例来源:origin: org.freemarker/com.springsource.freemarker
private void handleTemplateException(TemplateException te)
throws TemplateException
{
// Logic to prevent double-handling of the exception in
// nested visit() calls.
if(lastThrowable == te) {
throw te;
}
lastThrowable = te;
// Log the exception
if(logger.isErrorEnabled()) {
logger.error("Template processing error: " + StringUtil.jQuoteNoXSS(te.getMessage()), te);
}
// Stop exception is not passed to the handler, but
// explicitly rethrown.
if(te instanceof StopException) {
throw te;
}
// Finally, pass the exception to the handler
getTemplateExceptionHandler().handleTemplateException(te, this, out);
}
代码示例来源:origin: org.freemarker/freemarker
static public void useSunInternalXPathSupport() throws Exception {
Class.forName("com.sun.org.apache.xpath.internal.XPath");
Class c = Class.forName("freemarker.ext.dom.SunInternalXalanXPathSupport");
synchronized (STATIC_LOCK) {
xpathSupportClass = c;
}
LOG.debug("Using Sun's internal Xalan classes for XPath support");
}
内容来源于网络,如有侵权,请联系作者删除!