Java Code Examples for org.apache.log4j.Logger#warn()
The following examples show how to use
org.apache.log4j.Logger#warn() .
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: PerfLog.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
public static void logMappingSguidAndUniqueId(Logger logger, byte[] payload, String uniqueId) { try { SingleMessage sm = (SingleMessage)jaxContextCentralizer.toObject(SingleMessage.class, payload); SingleMessageWrapper smw = new SingleMessageWrapper(sm); List<PharmaceuticalCareEventType> listEvent = smw.getAllEventsOfType(PharmaceuticalCareEventType.class); Iterator i$ = listEvent.iterator(); while(i$.hasNext()) { PharmaceuticalCareEventType event = (PharmaceuticalCareEventType)i$.next(); log(logger, "********** PERFLOG-INTERNAL: ", "MAPPING", (String)null, (Long)null, (Long)null, event.getId(), uniqueId); } } catch (GFDDPPException var8) { logger.warn("A problem occured when getting Payload for logging purpose", var8.getCause()); } }
Example 2
Source File: PerfLog.java From freehealth-connector with GNU Affero General Public License v3.0 | 6 votes |
private static void logSguid(Logger logger, String logIndicator, String className, String method, Long startTimeStamp, Long endTimeStamp, SingleMessageWrapper singleMessageWrapper) { List<PharmaceuticalCareEventType> listEvent = singleMessageWrapper.getAllEventsOfType(PharmaceuticalCareEventType.class); List<MedicationHistoryType> medicationHistoryTypes = singleMessageWrapper.getAllMedicationHistoryEntries(); if (!CollectionUtils.isNotEmpty(listEvent) && !CollectionUtils.isNotEmpty(medicationHistoryTypes)) { logger.warn("NO SGUID FOUND TO LOG"); } else { Iterator i$ = listEvent.iterator(); if (i$.hasNext()) { PharmaceuticalCareEventType event = (PharmaceuticalCareEventType)i$.next(); log(logger, logIndicator, className, method, startTimeStamp, endTimeStamp, event.getId(), (String)null); } i$ = medicationHistoryTypes.iterator(); if (i$.hasNext()) { MedicationHistoryType medicationHistoryType = (MedicationHistoryType)i$.next(); log(logger, logIndicator, className, method, startTimeStamp, endTimeStamp, medicationHistoryType.getSessionID(), (String)null); } } }
Example 3
Source File: SecurityUtil.java From lutece-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Checks if a String contains characters that could be used for a cross-site scripting attack. * * @param request * The HTTP request * @param strValue * a character String * @param strXssCharacters * a String wich contain a list of Xss characters to check in strValue * @return true if the String contains illegal characters */ public static boolean containsXssCharacters( HttpServletRequest request, String strValue, String strXssCharacters ) { boolean bContains = ( strXssCharacters == null ) ? StringUtil.containsXssCharacters( strValue ) : StringUtil.containsXssCharacters( strValue, strXssCharacters ); if ( bContains ) { Logger logger = Logger.getLogger( LOGGER_NAME ); logger.warn( "SECURITY WARNING : XSS CHARACTERS DETECTED" + dumpRequest( request ) ); } return bContains; }
Example 4
Source File: SWTUtils.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Run the given runnable in the SWT-Thread, log any RuntimeExceptions to the given log and block * until the runnable returns. * * @blocking */ public static void runSafeSWTSync(final Logger log, final Runnable runnable) { try { getDisplay().syncExec(ThreadUtils.wrapSafe(log, runnable)); } catch (SWTException e) { if (!PlatformUI.getWorkbench().isClosing()) throw e; log.warn( "could not execute runnable " + runnable + ", UI thread is not available", new StackTrace()); } }
Example 5
Source File: SecurityUtil.java From lutece-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Scan request parameters to see if there no malicious code. * * @param request * The HTTP request * @param strXssCharacters * a String wich contain a list of Xss characters to check in strValue * @return true if all parameters don't contains any special characters */ public static boolean containsCleanParameters( HttpServletRequest request, String strXssCharacters ) { String key; String [ ] values; Enumeration<String> e = request.getParameterNames( ); while ( e.hasMoreElements( ) ) { key = e.nextElement( ); values = request.getParameterValues( key ); int length = values.length; for ( int i = 0; i < length; i++ ) { if ( SecurityUtil.containsXssCharacters( request, values [i], strXssCharacters ) ) { Logger logger = Logger.getLogger( LOGGER_NAME ); logger.warn( "SECURITY WARNING : INVALID REQUEST PARAMETERS" + dumpRequest( request ) ); return false; } } } return true; }
Example 6
Source File: SWTUtils.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Run the given runnable in the SWT-Thread and log any RuntimeExceptions to the given log. * * @nonBlocking */ public static void runSafeSWTAsync(final Logger log, final Runnable runnable) { try { getDisplay().asyncExec(ThreadUtils.wrapSafe(log, runnable)); } catch (SWTException e) { if (!PlatformUI.getWorkbench().isClosing()) throw e; log.warn( "could not execute runnable " + runnable + ", UI thread is not available", new StackTrace()); } }
Example 7
Source File: LevelMatchFilterTestCase.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
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 8
Source File: Pipeline.java From swift-t with Apache License 2.0 | 5 votes |
/** * Heuristic score * * TODO: this is simplistic, since this doesn't incorporate whether the * variable is produced or consumed by the child or the exact mechanism * of data transfer * @param logger * @param t * @return */ private static int costOfPassing(Logger logger, Type t) { if (Types.isFile(t)) { // Files tend to be large return 20; } else if (Types.isBlob(t)) { // Blobs also tend to be fairly large return 5; } else if (Types.isPrimFuture(t) || Types.isRef(t)) { // Baseline cost is plain future: 1 return 1; } else if (Types.isPrimValue(t)) { return 0; } else if (Types.isContainer(t)) { return 1; } else if (Types.isStruct(t)) { StructType st = (StructType)t.getImplType(); int totalCost = 0; for (StructField sf: st.fields()) { totalCost += costOfPassing(logger, sf.type()); } return totalCost; } else { logger.warn("Don't know how to calculate passing cost for type: " + t); return 1; } }
Example 9
Source File: LoggerHelper.java From niubi-job with Apache License 2.0 | 5 votes |
public static void warn(Class<?> clazz, String message, Throwable throwable) { AssertHelper.notNull(message, "message can't be null!"); if (clazz == null) { clazz = LoggerHelper.class; } Logger logger = Logger.getLogger(clazz); if (throwable == null) { logger.warn(message); } if (throwable != null) { logger.warn(message, throwable); } }
Example 10
Source File: OssmeterLoggerTest.java From scava with Eclipse Public License 2.0 | 5 votes |
@Test public void testFile() { Properties props = new Properties(); props.setProperty("log.type", "file"); props.setProperty("log.file.path", "/tmp/ossmeterlog.log"); Configuration.getInstance().setConfigurationProperties(props); Logger logger = OssmeterLogger.getLogger("scava.logger.test"); logger.warn("I'm warning you."); logger.debug("The bus has hit the house."); }
Example 11
Source File: Log4JAspect.java From yunsleLive_room with MIT License | 5 votes |
@After("execution(* com.test.service.impl.*.*(..))") public void afterAction(JoinPoint joinpoint) { Logger logger = Logger.getLogger(joinpoint.getTarget().getClass().getName()); String logStr=joinpoint.getTarget().getClass().getName()+"类的" +joinpoint.getSignature().getName()+"方法执行结束******End******"; System.out.println(logStr); logger.warn(logStr); }
Example 12
Source File: ShardedTableMapFile.java From datawave with Apache License 2.0 | 5 votes |
/** * Continually scans the metdata table attempting to get the split locations for the shard table. * * @param log * logger for reporting errors * @param accumuloHelper * Accumulo helper to query shard locations * @param shardedTableName * name of the shard table--the table whose locations we are querying * @return a map of split (endRow) to the location of those tablets in accumulo */ public static Map<Text,String> getLocations(Logger log, AccumuloHelper accumuloHelper, String shardedTableName) { // split (endRow) -> String location mapping Map<Text,String> splitToLocation = new TreeMap<>(); boolean keepRetrying = true; int attempts = 0; while (keepRetrying && attempts < MAX_RETRY_ATTEMPTS) { try { TableOperations tableOps = accumuloHelper.getConnector().tableOperations(); attempts++; // if table does not exist don't want to catch the errors and end up in infinite loop if (!tableOps.exists(shardedTableName)) { log.error("Table " + shardedTableName + " not found, skipping split locations for missing table"); } else { Range range = new Range(); Locations locations = tableOps.locate(shardedTableName, Collections.singletonList(range)); List<TabletId> tabletIds = locations.groupByRange().get(range); tabletIds.stream().filter(tId -> tId.getEndRow() != null) .forEach(tId -> splitToLocation.put(tId.getEndRow(), locations.getTabletLocation(tId))); } // made it here, no errors so break out keepRetrying = false; } catch (Exception e) { log.warn(e.getClass().getName() + ":" + e.getMessage() + " ... retrying ...", e); UtilWaitThread.sleep(3000); splitToLocation.clear(); } } return splitToLocation; }
Example 13
Source File: PerfLog.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private static void logSguid(Logger logger, String logIndicator, String className, String method, Long startTimeStamp, Long endTimeStamp, byte[] payload) { try { logSguid(logger, logIndicator, className, method, startTimeStamp, endTimeStamp, (SingleMessage)jaxContextCentralizer.toObject(SingleMessage.class, payload)); } catch (GFDDPPException var8) { logger.warn("A problem occured when getting Payload for logging purpose", var8.getCause()); } }
Example 14
Source File: SpliceLogUtils.java From spliceengine with GNU Affero General Public License v3.0 | 4 votes |
public static void warn(Logger log, String message,Throwable error) { log.warn(message,error); }
Example 15
Source File: Serianalyzer.java From serianalyzer with GNU General Public License v3.0 | 4 votes |
/** * @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 16
Source File: ArrayBuild.java From swift-t with Apache License 2.0 | 4 votes |
/** * Select the location to insert the array build instruction * @param block * @param array * @param keys * @param vals * @return */ private ListIterator<Statement> findArrayBuildPos(Logger logger, Block block, InitState outerInit, Var array, List<Arg> keys, List<Arg> vals) { // Place the array build instruction as early as possible, once all // inputs are initialized Set<Var> needsInit = new HashSet<Var>(); // array variable may need to be initialized if (InitVariables.varMustBeInitialized(array, true)) { if (!outerInit.initVars.contains(array)) { needsInit.add(array); } } for (Arg key: keys) { if (key.isVar()) { // Assert to check assumptions match init var analysis assert (InitVariables.assignBeforeRead(key.getVar())); // Key must be assigned if (!outerInit.assignedVals.contains(key.getVar())) { needsInit.add(key.getVar()); } } } for (Arg val: vals) { if (val.isVar()) { Var var = val.getVar(); if (InitVariables.assignBeforeRead(var) && !outerInit.assignedVals.contains(var)) { // Must assign value needsInit.add(var); } else if (InitVariables.varMustBeInitialized(var, false) && !outerInit.initVars.contains(var)) { // Must init alias needsInit.add(var); } } } InitState blockInit = outerInit.enterBlock(block); // Move forward until all variables are initialized ListIterator<Statement> insertPos = block.statementIterator(); while (insertPos.hasNext() && !needsInit.isEmpty()) { Statement stmt = insertPos.next(); InitVariables.updateInitVars(logger, stmt, blockInit, false); // Check to see if everything is ready now // TODO: iterating over this every time is inefficient, but probably // good enough Iterator<Var> it = needsInit.iterator(); while (it.hasNext()) { Var v = it.next(); if (InitVariables.assignBeforeRead(v)) { if (blockInit.assignedVals.contains(v)) { it.remove(); } } else if (InitVariables.varMustBeInitialized(v, false)) { if (blockInit.initVars.contains(v)) { it.remove(); } } } } if (!needsInit.isEmpty()) { logger.warn("STC internal warning: wasn't able to determine that " + needsInit + " were initialized"); } return insertPos; }
Example 17
Source File: StructBuild.java From swift-t with Apache License 2.0 | 4 votes |
private void structBuildRec(Logger logger, Block block) { // Track all assigned struct paths ListMultimap<Var, List<String>> assignedPaths = ArrayListMultimap.create(); // Find all struct assign statements in block for (Statement stmt: block.getStatements()) { if (stmt.type() == StatementType.INSTRUCTION) { Instruction inst = stmt.instruction(); if (inst.op == Opcode.STRUCT_STORE_SUB) { Var struct = inst.getOutput(0); List<Arg> inputs = inst.getInputs(); List<Arg> fields = inputs.subList(1, inputs.size()); assignedPaths.put(struct, Arg.extractStrings(fields)); } } } // Check if all fields were assigned for (Var candidate: assignedPaths.keySet()) { StructType candidateType = (StructType)candidate.type().getImplType(); Set<List<String>> expectedPaths = allAssignablePaths(candidateType); List<List<String>> assigned = assignedPaths.get(candidate); logger.trace("Check candidate " + candidate.name() + "\n" + "expected: " + expectedPaths + "\n" + "assigned: " + assigned); for (List<String> path: assigned) { Type fieldType; try { fieldType = candidateType.fieldTypeByPath(path); } catch (TypeMismatchException e) { throw new STCRuntimeError(e.getMessage()); } Set<List<String>> assignedSubPaths; if (Types.isStruct(fieldType)) { // Handle case where we assign a substruct StructType structFieldType = (StructType)fieldType.getImplType(); assignedSubPaths = allAssignablePaths(structFieldType, path); } else { assignedSubPaths = Collections.singleton(path); } for (List<String> assignedPath: assignedSubPaths) { boolean found = expectedPaths.remove(assignedPath); if (!found) { logger.warn("Invalid or double-assigned struct field: " + candidate.name() + "." + assignedPath); } } } if (expectedPaths.isEmpty()) { doStructBuildTransform(logger, block, candidate, assigned.size()); } else if (logger.isTraceEnabled()) { logger.trace("Fields not assigned: " + expectedPaths); } } for (Continuation cont: block.allComplexStatements()) { for (Block cb: cont.getBlocks()) { structBuildRec(logger, cb); } } }
Example 18
Source File: ForeachLoops.java From swift-t with Apache License 2.0 | 4 votes |
@Override public Pair<Boolean, List<Continuation>> tryUnroll(Logger logger, FnID function, Block outerBlock) { logger.trace("DesiredUnroll for " + loopName + ": " + desiredUnroll); boolean expandLoops = isExpandLoopsEnabled(); boolean fullUnroll = isFullUnrollEnabled(); if (!Types.isIntVal(start)) { /* * TODO: only unroll integer ranges now - don't want to deal with * floating point rounding issues */ return NO_UNROLL; } if (!this.unrolled && this.desiredUnroll > 1) { // Unroll explicitly marked loops if (this.loopCounterVar != null) { logger.warn("Can't unroll range loop with counter variable yet," + " ignoring unroll annotation"); return NO_UNROLL; } return Pair.create(true, doUnroll(logger, function, outerBlock, desiredUnroll)); } else if (expandLoops || fullUnroll) { long instCount = loopBody.getInstructionCount(); long iterCount = constIterCount(); if (instCount == 0) { return NO_UNROLL; } if (expandLoops && iterCount >= 0) { // See if the loop has a small number of iterations, could just expand; if (iterCount <= getUnrollMaxIters(true)) { long extraInstructions = instCount * (iterCount - 1); if (extraInstructions <= getUnrollMaxExtraInsts(true)) { return Pair.create(true, doUnroll(logger, function, outerBlock, (int)iterCount)); } } } if (!fullUnroll) { logger.trace("Full unrolled not enabled"); return NO_UNROLL; } if (this.unrolled) { // Don't do extra unrolling unless we're just expanding a small loop return NO_UNROLL; } // Finally, maybe unroll a few iterations long threshold = getUnrollMaxExtraInsts(false); long unrollFactor = Math.min(getUnrollMaxIters(false), (threshold / instCount) + 1); if (unrollFactor > 1) { return Pair.create(true, doUnroll(logger, function, outerBlock, (int)unrollFactor)); } } return NO_UNROLL; }
Example 19
Source File: Main.java From swift-t with Apache License 2.0 | 4 votes |
private static void runPreprocessor(Logger logger, String input, String output, List<String> preprocArgs) { List<String> cmd = new ArrayList<String>(); /* -undef flag is provided to disable non-standard macros */ if (useGCCProcessor()) { // We use gcc -E because cpp is broken on Mac GCC 4.2.1 // Cf. http://stackoverflow.com/questions/4137923 cmd.addAll(Arrays.asList("gcc", "-E", "-undef", "-x", "c", input, "-o", output)); } else { cmd.addAll(Arrays.asList("cpp", "-undef", input, output)); } for (String dir: Settings.getModulePath()) { cmd.add("-I"); cmd.add(dir); } for (String macro: preprocArgs) { cmd.add("-D"); cmd.add(macro); } String cmdString = StringUtils.join(cmd, ' '); try { logger.debug("Running cpp: " + cmdString); Process cpp = Runtime.getRuntime().exec(cmd.toArray(new String[]{})); int cppExitCode = -1; boolean done = false; do { try { cppExitCode = cpp.waitFor(); done = true; } catch (InterruptedException ex) { // Continue on after spurious interrupt } } while (!done); StringWriter sw = new StringWriter(); IOUtils.copy(cpp.getErrorStream(), sw, "UTF-8"); String cppStderr = sw.toString(); logger.debug("Preprocessor exit code: " + cppExitCode); logger.debug("Preprocessor stderr: " + cppStderr); if (cppExitCode != 0) { // Print stderr message first, then clarify that failure was in preprocessor System.out.println(cppStderr); System.out.println("Aborting due to failure in cpp preprocessor invoked as: " + cmdString + ". " + ("Exit code was " + cppExitCode + ". ")); System.exit(1); } else if (cppStderr.length() != 0){ logger.warn("Preprocessor warnings:\n" + cppStderr); } } catch (IOException e) { System.out.println("I/O error while launching preprocessor with command line:" + cmdString + ": " + e.getMessage()); System.exit(1); } }
Example 20
Source File: SecurityUtil.java From lutece-core with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Validate an internal redirect URL to avoid internal open redirect. (Use this function only if the use of internal url redirect keys is not possible. For * external url redirection control, use the plugin plugin-verifybackurl) * * the url should : - not be blank (null or empty string or spaces) - not start with "http://" or "https://" or "//" OR match the base URL or any URL in the * pattern list * * example with a base url "https://lutece.fr/ : - valid : myapp/jsp/site/Portal.jsp , Another.jsp , https://lutece.fr/myapp/jsp/site/Portal.jsp - invalid : * http://anothersite.com , https://anothersite.com , //anothersite.com , file://my.txt , ... * * * @param strUrl * the Url to validate * @param request * the current request (containing the baseUrl) * @param strAntPathMatcherPatterns * a comma separated list of AntPathMatcher patterns, as "http://**.lutece.com,https://**.lutece.com" * @return true if valid */ public static boolean isInternalRedirectUrlSafe( String strUrl, HttpServletRequest request, String strAntPathMatcherPatterns ) { if ( StringUtils.isBlank( strUrl ) ) { return true; // this is not a valid redirect Url, but it is not unsafe } // filter schemes boolean [ ] conditions = new boolean [ ] { !strUrl.startsWith( "//" ), !strUrl.startsWith( "http:" ), !strUrl.startsWith( "https:" ), !strUrl.contains( "://" ), !strUrl.startsWith( "javascript:" ) }; if ( BooleanUtils.and( conditions ) ) { return true; // should be a relative path } // compare with current baseUrl if ( strUrl.startsWith( AppPathService.getBaseUrl( request ) ) ) { return true; } // compare with allowed url patterns if ( !StringUtils.isBlank( strAntPathMatcherPatterns ) ) { AntPathMatcher pathMatcher = new AntPathMatcher( ); String [ ] strAntPathMatcherPatternsTab = strAntPathMatcherPatterns.split( CONSTANT_COMMA ); for ( String pattern : strAntPathMatcherPatternsTab ) { if ( pattern != null && pathMatcher.match( pattern, strUrl ) ) { return true; } } } // the Url does not match the allowed patterns Logger logger = Logger.getLogger( LOGGER_NAME ); logger.warn( "SECURITY WARNING : OPEN_REDIRECT DETECTED : " + dumpRequest( request ) ); return false; }