本文整理了Java中freemarker.log.Logger.warn()
方法的一些代码示例,展示了Logger.warn()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.warn()
方法的具体详情如下:
包路径:freemarker.log.Logger
类名称:Logger
方法名:warn
[英]Logs a warning message.
[中]记录一条警告消息。
代码示例来源: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
private static ClassLoader tryGetThreadContextClassLoader() {
ClassLoader tccl;
try {
tccl = Thread.currentThread().getContextClassLoader();
} catch (SecurityException e) {
// Suppress
tccl = null;
LOG.warn("Can't access Thread Context ClassLoader", e);
}
return tccl;
}
代码示例来源:origin: org.freemarker/freemarker
public void unreferenced() {
try {
UnicastRemoteObject.unexportObject(this, false);
} catch (NoSuchObjectException e) {
LOG.warn("Failed to unexport RMI debugger listener", e);
}
}
代码示例来源: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.freemarker/freemarker
public static Integer getSystemProperty(final String key, final int defValue) {
try {
return (Integer) AccessController.doPrivileged(
new PrivilegedAction()
{
public Object run() {
return Integer.getInteger(key, defValue);
}
});
} catch (AccessControlException e) {
LOG.warn("Insufficient permissions to read system property " +
StringUtil.jQuote(key) + ", using default value " + defValue);
return Integer.valueOf(defValue);
}
}
}
代码示例来源:origin: org.freemarker/freemarker
public void run() {
try {
ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
ObjectInputStream in = new ObjectInputStream(s.getInputStream());
byte[] challenge = new byte[512];
R.nextBytes(challenge);
out.writeInt(220); // protocol version
out.writeObject(challenge);
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(password);
md.update(challenge);
byte[] response = (byte[]) in.readObject();
if (Arrays.equals(response, md.digest())) {
out.writeObject(debuggerStub);
} else {
out.writeObject(null);
}
} catch (Exception e) {
LOG.warn("Connection to " + s.getInetAddress().getHostAddress() + " abruply broke", e);
}
}
代码示例来源:origin: org.freemarker/freemarker
private void endEvaluation() throws JspException {
if (needPop) {
pageContext.popWriter();
needPop = false;
}
if (tag.doEndTag() == Tag.SKIP_PAGE) {
LOG.warn("Tag.SKIP_PAGE was ignored from a " + tag.getClass().getName() + " tag.");
}
}
代码示例来源:origin: org.freemarker/freemarker
private static ExpressionFactory findExpressionFactoryImplementation() {
ExpressionFactory ef = tryExpressionFactoryImplementation("com.sun");
if (ef == null) {
ef = tryExpressionFactoryImplementation("org.apache");
if (ef == null) {
LOG.warn("Could not find any implementation for " +
ExpressionFactory.class.getName());
}
}
return ef;
}
代码示例来源:origin: org.freemarker/freemarker
@SuppressFBWarnings(value={ "MSF_MUTABLE_SERVLET_FIELD", "DC_DOUBLECHECK" }, justification="Performance trick")
private void logWarnOnObjectWrapperMismatch() {
// Deliberately uses double check locking.
if (wrapper != config.getObjectWrapper() && !objectWrapperMismatchWarnLogged && LOG.isWarnEnabled()) {
final boolean logWarn;
synchronized (this) {
logWarn = !objectWrapperMismatchWarnLogged;
if (logWarn) {
objectWrapperMismatchWarnLogged = true;
}
}
if (logWarn) {
LOG.warn(
this.getClass().getName()
+ ".wrapper != config.getObjectWrapper(); possibly the result of incorrect extension of "
+ FreemarkerServlet.class.getName() + ".");
}
}
}
代码示例来源:origin: org.freemarker/freemarker
public static String getSystemProperty(final String key, final String defValue) {
try {
return (String) AccessController.doPrivileged(
new PrivilegedAction()
{
public Object run() {
return System.getProperty(key, defValue);
}
});
} catch (AccessControlException e) {
LOG.warn("Insufficient permissions to read system property " +
StringUtil.jQuoteNoXSS(key) + ", using default value " +
StringUtil.jQuoteNoXSS(defValue));
return defValue;
}
}
代码示例来源: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 addConstructorsToClassIntrospectionData(final Map<Object, Object> introspData,
Class<?> clazz) {
try {
Constructor<?>[] ctors = clazz.getConstructors();
if (ctors.length == 1) {
Constructor<?> ctor = ctors[0];
introspData.put(CONSTRUCTORS_KEY, new SimpleMethod(ctor, ctor.getParameterTypes()));
} else if (ctors.length > 1) {
OverloadedMethods overloadedCtors = new OverloadedMethods(bugfixed);
for (int i = 0; i < ctors.length; i++) {
overloadedCtors.addConstructor(ctors[i]);
}
introspData.put(CONSTRUCTORS_KEY, overloadedCtors);
}
} catch (SecurityException e) {
LOG.warn("Can't discover constructors for class " + clazz.getName(), e);
}
}
代码示例来源:origin: org.freemarker/freemarker
private static TemplateLoader createDefaultTemplateLoader(
Version incompatibleImprovements, TemplateLoader existingTemplateLoader) {
if (incompatibleImprovements.intValue() < _TemplateAPI.VERSION_INT_2_3_21) {
if (existingTemplateLoader instanceof LegacyDefaultFileTemplateLoader) {
return existingTemplateLoader;
}
try {
return new LegacyDefaultFileTemplateLoader();
} catch (Exception e) {
CACHE_LOG.warn("Couldn't create legacy default TemplateLoader which accesses the current directory. "
+ "(Use new Configuration(Configuration.VERSION_2_3_21) or higher to avoid this.)", e);
return null;
}
} else {
return null;
}
}
代码示例来源:origin: org.freemarker/freemarker
public Object findTemplateSource(String name) throws IOException {
String fullPath = subdirPath + name;
if (attemptFileAccess) {
// First try to open as plain file (to bypass servlet container resource caches).
try {
String realPath = servletContext.getRealPath(fullPath);
if (realPath != null) {
File file = new File(realPath);
if (file.canRead() && file.isFile()) {
return file;
}
}
} catch (SecurityException e) {
;// ignore
}
}
// If it fails, try to open it with servletContext.getResource.
URL url = null;
try {
url = servletContext.getResource(fullPath);
} catch (MalformedURLException e) {
LOG.warn("Could not retrieve resource " + StringUtil.jQuoteNoXSS(fullPath),
e);
return null;
}
return url == null ? null : new URLTemplateSource(url, getURLConnectionUsesCaches());
}
代码示例来源:origin: org.freemarker/freemarker
/**
* Creates a {@link Map} with the content as described for the return value of {@link #get(Class)}.
*/
private Map<Object, Object> createClassIntrospectionData(Class<?> clazz) {
final Map<Object, Object> introspData = new HashMap<Object, Object>();
if (exposeFields) {
addFieldsToClassIntrospectionData(introspData, clazz);
}
final Map<MethodSignature, List<Method>> accessibleMethods = discoverAccessibleMethods(clazz);
addGenericGetToClassIntrospectionData(introspData, accessibleMethods);
if (exposureLevel != BeansWrapper.EXPOSE_NOTHING) {
try {
addBeanInfoToClassIntrospectionData(introspData, clazz, accessibleMethods);
} catch (IntrospectionException e) {
LOG.warn("Couldn't properly perform introspection for class " + clazz, e);
introspData.clear(); // FIXME NBC: Don't drop everything here.
}
}
addConstructorsToClassIntrospectionData(introspData, clazz);
if (introspData.size() > 1) {
return introspData;
} else if (introspData.size() == 0) {
return Collections.emptyMap();
} else { // map.size() == 1
Entry<Object, Object> e = introspData.entrySet().iterator().next();
return Collections.singletonMap(e.getKey(), e.getValue());
}
}
代码示例来源: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
private void addListener(EventListener listener) {
boolean added = false;
if (listener instanceof ServletContextAttributeListener) {
addListener(servletContextAttributeListeners, listener);
added = true;
}
if (listener instanceof ServletContextListener) {
addListener(servletContextListeners, listener);
added = true;
}
if (listener instanceof HttpSessionAttributeListener) {
addListener(httpSessionAttributeListeners, listener);
added = true;
}
if (listener instanceof HttpSessionListener) {
addListener(httpSessionListeners, listener);
added = true;
}
if (!added) {
LOG.warn(
"Listener of class " + listener.getClass().getName() +
"wasn't registered as it doesn't implement any of the " +
"recognized listener interfaces.");
}
}
代码示例来源: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
} catch (IOException e) {
if (LOG.isWarnEnabled()) {
LOG.warn("Ignored classpath TLD location " + StringUtil.jQuoteNoXSS(tldResourcePath)
+ " because of error", e);
内容来源于网络,如有侵权,请联系作者删除!