use of org.apache.log4j.HTMLLayout in project Lucee by lucee.
the class Log4jUtil method getLayout.
public static final Layout getLayout(ClassDefinition cd, Map<String, String> layoutArgs) {
if (layoutArgs == null)
layoutArgs = new HashMap<String, String>();
// Layout
Layout layout = null;
if (cd != null && cd.hasClass()) {
// Classic Layout
if (ClassicLayout.class.getName().equalsIgnoreCase(cd.getClassName()))
layout = new ClassicLayout();
else // HTML Layout
if (HTMLLayout.class.getName().equalsIgnoreCase(cd.getClassName())) {
HTMLLayout html = new HTMLLayout();
layout = html;
// Location Info
Boolean locInfo = Caster.toBoolean(layoutArgs.get("locationinfo"), null);
if (locInfo != null)
html.setLocationInfo(locInfo.booleanValue());
else
locInfo = Boolean.FALSE;
layoutArgs.put("locationinfo", locInfo.toString());
// Title
String title = Caster.toString(layoutArgs.get("title"), "");
if (!StringUtil.isEmpty(title, true))
html.setTitle(title);
layoutArgs.put("title", title);
} else // XML Layout
if (XMLLayout.class.getName().equalsIgnoreCase(cd.getClassName())) {
XMLLayout xml = new XMLLayout();
layout = xml;
// Location Info
Boolean locInfo = Caster.toBoolean(layoutArgs.get("locationinfo"), null);
if (locInfo != null)
xml.setLocationInfo(locInfo.booleanValue());
else
locInfo = Boolean.FALSE;
layoutArgs.put("locationinfo", locInfo.toString());
// Properties
Boolean props = Caster.toBoolean(layoutArgs.get("properties"), null);
if (props != null)
xml.setProperties(props.booleanValue());
else
props = Boolean.FALSE;
layoutArgs.put("properties", props.toString());
} else // Pattern Layout
if (PatternLayout.class.getName().equalsIgnoreCase(cd.getClassName())) {
PatternLayout patt = new PatternLayout();
layout = patt;
// pattern
String pattern = Caster.toString(layoutArgs.get("pattern"), null);
if (!StringUtil.isEmpty(pattern, true))
patt.setConversionPattern(pattern);
else {
patt.setConversionPattern(DEFAULT_PATTERN);
layoutArgs.put("pattern", DEFAULT_PATTERN);
}
} else // class defintion
{
Object obj = ClassUtil.loadInstance(cd.getClazz(null), null, null);
if (obj instanceof Layout) {
layout = (Layout) obj;
Iterator<Entry<String, String>> it = layoutArgs.entrySet().iterator();
Entry<String, String> e;
while (it.hasNext()) {
e = it.next();
try {
Reflector.callSetter(obj, e.getKey(), e.getValue());
} catch (PageException e1) {
// TODO log
SystemOut.printDate(e1);
}
}
}
}
}
if (layout != null)
return layout;
return new ClassicLayout();
}
use of org.apache.log4j.HTMLLayout in project uavstack by uavorg.
the class Log4jHookProxy method figureoutLogConfiguration.
@SuppressWarnings("unchecked")
private void figureoutLogConfiguration(Logger Logger, LinkedList<LogProfileInfo> list, String appid) {
Enumeration<Appender> appenders = Logger.getAllAppenders();
while (appenders != null && appenders.hasMoreElements()) {
LogProfileInfo logProfileInfo = new LogProfileInfo();
if (appid != null) {
logProfileInfo.setAppId(appid);
}
logProfileInfo.setLogType(LogProfileInfo.LogType.Log4j);
Map<String, String> attributes = new HashMap<String, String>();
attributes.put(LogProfileInfo.ENGINE, "log4j");
Appender appender = appenders.nextElement();
if (!(appender instanceof FileAppender)) {
continue;
}
FileAppender fileAppender = (FileAppender) appender;
Layout layout = fileAppender.getLayout();
if (null != layout) {
if (layout instanceof PatternLayout) {
PatternLayout patternLayout = (PatternLayout) fileAppender.getLayout();
attributes.put(LogProfileInfo.PATTERN, patternLayout.getConversionPattern());
} else if (layout instanceof HTMLLayout) {
attributes.put(LogProfileInfo.PATTERN, "HTMLLayout");
} else if (layout instanceof SimpleLayout) {
attributes.put(LogProfileInfo.PATTERN, "SimpleLayout");
} else if (layout instanceof TTCCLayout) {
attributes.put(LogProfileInfo.PATTERN, "TTCCLayout");
}
}
boolean useBuffIO = fileAppender.getBufferedIO();
if (useBuffIO == true) {
attributes.put(LogProfileInfo.BUFFER_SIZE, String.valueOf(fileAppender.getBufferSize()));
attributes.put(LogProfileInfo.BUFFRT_IO, String.valueOf(useBuffIO));
}
logProfileInfo.setFilePath(fileAppender.getFile());
logProfileInfo.setAttributes(attributes);
list.add(logProfileInfo);
}
}
use of org.apache.log4j.HTMLLayout in project jop by jop-devel.
the class LogConfig method setReportLoggers.
@SuppressWarnings({ "ResultOfMethodCallIgnored" })
public void setReportLoggers(File errorLog, File infoLog) throws IOException {
this.errorLog = errorLog;
this.infoLog = infoLog;
if (errorLog != null) {
errorLog.delete();
FileAppender eapp = new FileAppender(new HTMLLayout(), errorLog.getPath());
eapp.setName("AERROR");
eapp.setThreshold(Level.WARN);
Logger.getRootLogger().addAppender(eapp);
}
if (infoLog != null) {
infoLog.delete();
FileAppender iapp = new FileAppender(new HTMLLayout(), infoLog.getPath());
// TODO maybe make level of info logger configurable (one of INFO, DEBUG, ALL)?
iapp.setThreshold(Level.ALL);
iapp.setName("AINFO");
Logger.getRootLogger().addAppender(iapp);
}
}
Aggregations