Java Code Examples for org.apache.log4j.Logger#debug()

The following examples show how to use org.apache.log4j.Logger#debug() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScapDownloadAction.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    Logger log = Logger.getLogger(ScapDownloadAction.class);
    RequestContext context = new RequestContext(request);
    User user = context.getCurrentUser();
    Long sid = context.getRequiredParam("sid");
    Server server = SystemManager.lookupByIdAndUser(sid, user);
    Long xid = context.getRequiredParam("xid");
    XccdfTestResult testResult = ScapFactory.lookupTestResultByIdAndSid(xid,
            server.getId());
    String filename = context.getRequiredParamAsString("name");
    ScapResultFile file = new ScapResultFile(testResult, filename);

    log.debug("Serving " + file);
    if (!file.getHTML()) {
        response.setHeader("Content-Disposition", "attachment; filename=" + filename);
    }
    return file;
}
 
Example 2
Source File: AbstractTableConfigHelper.java    From datawave with Apache License 2.0 6 votes vote down vote up
/**
 * Set the locality group configuration for a table if necessary. If the specified configuration is not already included in the current group configuration,
 * then the new locality groups are merged with the current set and the locality groups are reset for the table.
 * 
 * @param tableName
 * @param newLocalityGroups
 * @param tops
 * @param log
 * @throws AccumuloException
 * @throws TableNotFoundException
 * @throws AccumuloSecurityException
 */
protected void setLocalityGroupConfigurationIfNecessary(String tableName, Map<String,Set<Text>> newLocalityGroups, TableOperations tops, Logger log)
                throws AccumuloException, TableNotFoundException, AccumuloSecurityException {
    if (areLocalityGroupsConfigured(tableName, newLocalityGroups, tops)) {
        log.debug("Verified the following locality groups are configured for " + tableName + ": " + newLocalityGroups);
        return;
    }
    
    log.info("Creating the locality groups for " + tableName + ": " + newLocalityGroups);
    Map<String,Set<Text>> localityGroups = tops.getLocalityGroups(tableName);
    for (Map.Entry<String,Set<Text>> entry : newLocalityGroups.entrySet()) {
        Set<Text> families = localityGroups.get(entry.getKey());
        if (families == null) {
            families = new HashSet<>();
            localityGroups.put(entry.getKey(), families);
        }
        families.addAll(entry.getValue());
    }
    tops.setLocalityGroups(tableName, localityGroups);
    log.info("Reset the locality groups for " + tableName + " to " + localityGroups);
}
 
Example 3
Source File: SerianalyzerState.java    From serianalyzer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param method
 */
public void trackKnown ( MethodReference method ) {
    MethodReference cmp = method.comparable();

    Logger cl = Verbose.getPerMethodLogger(cmp);
    if ( cl.isDebugEnabled() ) {
        cl.debug(String.format("Handled call to %s", cmp)); //$NON-NLS-1$
    }

    Set<MethodReference> set = this.known.get(cmp);

    if ( set == null ) {
        set = new HashSet<>();
        this.known.put(cmp, set);
    }
    set.add(method);
}
 
Example 4
Source File: ScapDownloadAction.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected StreamInfo getStreamInfo(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    Logger log = Logger.getLogger(ScapDownloadAction.class);
    RequestContext context = new RequestContext(request);
    User user = context.getCurrentUser();
    Long sid = context.getRequiredParam("sid");
    Server server = SystemManager.lookupByIdAndUser(sid, user);
    Long xid = context.getRequiredParam("xid");
    XccdfTestResult testResult = ScapFactory.lookupTestResultByIdAndSid(xid,
            server.getId());
    String filename = context.getRequiredParamAsString("name");
    ScapResultFile file = new ScapResultFile(testResult, filename);

    log.debug("Serving " + file);
    if (!file.getHTML()) {
        response.setHeader("Content-Disposition", "attachment; filename=" + filename);
    }
    return file;
}
 
Example 5
Source File: Util.java    From oneops with Apache License 2.0 5 votes vote down vote up
/**
 * Log map double.
 *
 * @param name the name
 * @param h the h
 * @param logger the logger
 */
public static void logMapDouble(String name, Map<String, Double> h, Logger logger) {
	StringBuilder sber = new StringBuilder("{");
	for (String k : h.keySet()) {
		sber.append(k).append(":").append(h.get(k)).append(",");
	}
	sber.append("}");
	logger.debug(name + " : " + sber);

}
 
Example 6
Source File: WebsocketLogUtil.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Print the headers associated with the initial Http Request.
 * The header details will be printed in the following format.
 * <p>
 * " >> Headers [channelContextId] [header name] : [header value]"
 *
 * @param log {@link Logger} object of the relevant class
 * @param msg {@link FullHttpRequest} response from the backend
 * @param ctx {@link ChannelHandlerContext} context
 */
public static void printHeaders(Logger log, FullHttpRequest msg, ChannelHandlerContext ctx) {
    //the direction is always inbound.
    String logStatement = getDirectionString(true) + "Headers " + resolveContextId(ctx) + " ";
    if (msg.headers() == null || msg.headers().isEmpty()) {
        log.debug(logStatement + "empty");
    } else {
        for (Map.Entry<String, String> entry : msg.headers().entries()) {
            log.debug(logStatement + entry.getKey() + ":" + entry.getValue());
        }
    }
}
 
Example 7
Source File: LogUtil.java    From zxl with Apache License 2.0 5 votes vote down vote up
public static void debug(Logger logger, String message, Exception exception) {
	if (logger.isDebugEnabled()) {
		if (exception != null) {
			logger.debug(message, exception);
		} else {
			logger.debug(message);
		}
	}
}
 
Example 8
Source File: DataMiningRExecutor.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public DataMiningResult setExecEnvironment(Logger logger, DataMiningResult result, HashMap params, DataMiningCommand command, IEngUserProfile userProfile,
		Boolean rerun, String documentLabel) throws Exception {

	logger.debug("IN");
	setupEnvonment(userProfile);
	logger.debug("Set up environment");
	// datasets preparation
	String error = datasetsExecutor.evalDatasetsNeeded(params);
	if (error.length() > 0) {
		result = new DataMiningResult();
		result.setError(error);
		return result;
	}
	logger.debug("Loaded datasets");

	// Files input preparation
	error = fileExecutor.evalFilesNeeded(params);
	if (error.length() > 0) {
		result = new DataMiningResult();
		result.setError(error);
		return result;
	}

	return result;

}
 
Example 9
Source File: Loader.java    From swift-k with Apache License 2.0 5 votes vote down vote up
/**
      Enter the text content of given files into the log
      @param name A token printed in the log
      @param file The text file to copy into the log
      @throws IOException 
    */
   public static void debugText(String name, File file) {
   	Logger textLogger = Logger.getLogger("swift.textfiles");
   	try {
   		if (textLogger.isDebugEnabled()) {
   			String text = TextFileLoader.loadFromFile(file);
   			textLogger.debug("BEGIN " + name + ":\n" + text + "\n");
   			textLogger.debug("END " + name + ":");
   		}
   	}
   	catch (IOException e) { 
   		logger.warn("Could not open: " + file);
   	}
}
 
Example 10
Source File: DataMiningPythonExecutor.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public DataMiningResult executeScript(Logger logger, DataMiningResult result, HashMap params, DataMiningCommand command, Output output,
		IEngUserProfile userProfile, Boolean rerun, String documentLabel) throws Exception {

	// evaluates script code
	scriptExecutor.evalScript(command, rerun);
	logger.debug("Evaluated script");
	// create output
	UserProfile profile = (UserProfile) userProfile;
	result = outputExecutor.evalOutput(output, scriptExecutor, documentLabel, (String) profile.getUserId());
	logger.debug("Got result");
	return result;

}
 
Example 11
Source File: LevelMatchFilterTestCase.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
void common(String msg) {
  Logger logger = Logger.getLogger("test");
  logger.trace(msg);
  logger.debug(msg);
  logger.info(msg);
  logger.warn(msg);
  logger.error(msg);
  logger.fatal(msg);
}
 
Example 12
Source File: Loader.java    From swift-k with Apache License 2.0 5 votes vote down vote up
public static void debugText(String name, String source) {
    Logger textLogger = Logger.getLogger("swift.textfiles");
    if (textLogger.isDebugEnabled()) {
        textLogger.debug("BEGIN " + name + ":\n" + source + "\n");
        textLogger.debug("END " + name + ":");
    }
}
 
Example 13
Source File: BIRTDataSet.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Method to update multiple data entries at once.<br />
 * Logs the statement and parameter in debug-level, executes update and logs error.<br />
 * Watch out: Oracle returns value -2 (= Statement.SUCCESS_NO_INFO) per line for success with no "lines touched" info<br />
 * 
 * @param childClassLogger
 * @param statement
 * @param values
 * @return
 * @throws Exception
 */
public int[] batchupdateEmbedded(Logger childClassLogger, String statement, List<Object[]> values) throws Exception {
	try {
		logSqlStatement(childClassLogger, "EMBEDDED: " + statement, "BatchUpdateParameterList(Size: " + values.size() + ")");
		int[] touchedLines = getEmbeddedJdbcTemplate().batchUpdate(statement, values);
		if (childClassLogger.isDebugEnabled()) {
			childClassLogger.debug("lines changed by update: " + Arrays.toString(touchedLines));
		}
		return touchedLines;
	} catch (RuntimeException e) {
		logSqlError(e, childClassLogger, "EMBEDDED: " + statement, "BatchUpdateParameterList(Size: " + values.size() + ")");
		throw e;
	}
}
 
Example 14
Source File: TaskHelper.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sends mail and logs the mail message if debug logging is enabled
 * @param mail - message to be sent
 * @param logger - logger assigned to the caller
 */
public static void sendMail(Mail mail, Logger logger) {
    if (logger != null && logger.isDebugEnabled()) {
        logger.debug("Sending mail message:\n" + mail.toString());
    }
    mail.send();
}
 
Example 15
Source File: LoopUnroller.java    From swift-t with Apache License 2.0 5 votes vote down vote up
@Override
public void optimize(Logger logger, Program prog) {
  for (Function f: prog.functions()) {
    logger.debug("looking to unroll loops in " + f.id());
    if (unrollLoops(logger, prog, f, f.mainBlock())) {
      // Unrolling can introduce duplicate vars
      UniqueVarNames.makeVarNamesUnique(f, prog.allGlobals());
      FlattenNested.flattenNestedBlocks(f.mainBlock());
    }
  }
}
 
Example 16
Source File: AppLogService.java    From lutece-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Log a message object with the DEBUG level. It is logged in application.log
 *
 * @param strLogger
 *            The Logger name
 * @param objToLog
 *            the message object to log
 */
public static void debug( String strLogger, Object objToLog )
{
    Logger logger = Logger.getLogger( strLogger );

    if ( logger.isDebugEnabled( ) )
    {
        logger.debug( objToLog );
    }
}
 
Example 17
Source File: TypedProperties.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void print(Logger logger, String message) {
       logger.debug(message + " " + this);
}
 
Example 18
Source File: DebugLog4JTag.java    From openemm with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected final void logMessage(final Logger logger, final String msg, final Throwable t) {
	logger.debug(msg, t);
}
 
Example 19
Source File: Serianalyzer.java    From serianalyzer with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param method
 * @throws SerianalyzerException
 */
private void doCheckMethod ( MethodReference methodReference ) throws SerianalyzerException {

    Logger cl = Verbose.getPerMethodLogger(methodReference);

    if ( cl.isTraceEnabled() ) {
        cl.trace(String.format("Checking reference %s", methodReference)); //$NON-NLS-1$
    }

    long currentTimeMillis = System.currentTimeMillis();
    if ( currentTimeMillis - this.lastOutput > OUTPUT_EVERY ) {
        log.info("Currently to check " + this.getState().getToCheck().size() + " known " + this.getState().countAllKnown()); //$NON-NLS-1$ //$NON-NLS-2$
        log.info("Sample " + methodReference); //$NON-NLS-1$
        this.lastOutput = currentTimeMillis;
    }

    try ( InputStream data = this.input.getClassData(methodReference.getTypeNameString()) ) {
        if ( data == null ) {
            cl.error("No class data for " + methodReference.getTypeNameString()); //$NON-NLS-1$
            return;
        }

        if ( this.input.getConfig().isWhitelisted(methodReference) ) {
            if ( cl.isDebugEnabled() ) {
                cl.debug("Is whitelisted " + methodReference); //$NON-NLS-1$
            }
            return;
        }

        short flags = this.getIndex().getClassByName(methodReference.getTypeName()).flags();
        if ( !methodReference.isStatic() && ( Modifier.isInterface(flags) || Modifier.isAbstract(flags) ) ) {
            log.debug("Resolved an interface/abstract class in non static call " + methodReference); //$NON-NLS-1$
        }

        ClassReader cr = new ClassReader(data);
        SerianalyzerClassMethodVisitor visitor = new SerianalyzerClassMethodVisitor(this, methodReference, methodReference.getTypeName());
        cr.accept(visitor, 0);

        Set<MethodReference> callers = this.state.getMethodCallers().get(methodReference.comparable());

        if ( !visitor.isFound() ) {
            if ( cl.isTraceEnabled() ) {
                cl.trace("Not found " + methodReference); //$NON-NLS-1$
            }

            boolean found = doCheckInSuperClasses(methodReference, cl, callers);

            if ( !found ) {
                cl.debug("Method not found in superclasses " + methodReference); //$NON-NLS-1$

                found = doCheckInInterfaces(methodReference, cl, callers);

                if ( !found && !methodReference.getTypeNameString().startsWith("java.lang.invoke.") ) { //$NON-NLS-1$
                    MethodReference cmp = methodReference.comparable();
                    if ( this.notFound.add(cmp) ) {
                        cl.warn("Method not found " + methodReference); //$NON-NLS-1$
                    }
                }
            }

        }
    }
    catch ( IOException e ) {
        log.error("Failed to read class " + methodReference.getTypeName()); //$NON-NLS-1$
    }
}
 
Example 20
Source File: FilterManager.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/** Initialise. */
private void initialise() {
    List<FilterConfigInterface> filterConfigList = getFilterConfigList();

    List<FilterName> filterNameList = new ArrayList<>();

    for (FilterConfigInterface filterConfig : filterConfigList) {
        filterNameList.add(filterConfig.getFilterConfiguration());
        String key = filterConfig.getFilterConfiguration().getFilterName();
        filterMap.put(key, filterConfig);
        filterTypeMap.put(filterConfig.getFilterClass(), filterConfig);
    }

    List<Class<?>> classList = new ArrayList<>();

    Logger logger = Logger.getLogger(getClass());

    for (FilterName function : filterNameList) {
        logger.debug(function.getFilterName());

        functionNameMap.put(function.getFilterName(), function);

        for (FilterNameParameter parameter : function.getParameterList()) {
            if (!classList.contains(parameter.getDataType())) {
                classList.add(parameter.getDataType());
            }
            logger.debug("\t" + parameter.getName() + "\t" + parameter.getDataType().getName());
        }

        if (!classList.contains(function.getReturnType())) {
            classList.add(function.getReturnType());
        }
        logger.debug("\tRet : " + function.getReturnType().getName());
    }

    logger.debug("\nClasses");
    for (Class<?> className : classList) {
        logger.debug(className.getName());
    }

    // CHECKSTYLE:OFF
    Class<?>[] allowedNumberTypes = {
        Number.class, Double.class, Float.class, Integer.class, Long.class
    };
    Class<?>[] allowedDoubleTypes = {
        Number.class, Double.class, Float.class, Integer.class, Long.class
    };
    Class<?>[] allowedFloatTypes = {
        Number.class, Double.class, Float.class, Integer.class, Long.class
    };
    Class<?>[] allowedIntegerTypes = {
        Number.class, Double.class, Float.class, Integer.class, Long.class
    };
    Class<?>[] allowedLongTypes = {
        Number.class, Double.class, Float.class, Integer.class, Long.class
    };
    Class<?>[] allowedBooleanTypes = {Boolean.class};
    Class<?>[] allowedStringTypes = {String.class};
    Class<?>[] allowedGeometryTypes = {
        Geometry.class, LineString.class, Point.class, MultiPoint.class, LinearRing.class
    };
    Class<?>[] allowedDateTypes = {Date.class};
    Class<?>[] allowedClassifierTypes = {RangedClassifier.class, Classifier.class};
    Class<?>[] allowedUnitTypes = {Unit.class};
    Class<?>[] allowedComparableTypes = {
        Number.class,
        Double.class,
        Float.class,
        Integer.class,
        Long.class,
        Date.class,
        String.class,
        Boolean.class
    };
    // CHECKSTYLE:ON

    populateAllowedTypes(Number.class, allowedNumberTypes);
    populateAllowedTypes(Double.class, allowedDoubleTypes);
    populateAllowedTypes(Float.class, allowedFloatTypes);
    populateAllowedTypes(Integer.class, allowedIntegerTypes);
    populateAllowedTypes(Long.class, allowedLongTypes);
    populateAllowedTypes(Boolean.class, allowedBooleanTypes);
    populateAllowedTypes(String.class, allowedStringTypes);
    populateAllowedTypes(Geometry.class, allowedGeometryTypes);
    populateAllowedTypes(org.opengis.geometry.Geometry.class, allowedGeometryTypes);
    populateAllowedTypes(Date.class, allowedDateTypes);
    populateAllowedTypes(Classifier.class, allowedClassifierTypes);
    populateAllowedTypes(Unit.class, allowedUnitTypes);
    populateAllowedTypes(Comparable.class, allowedComparableTypes);
}