Java Code Examples for org.apache.log4j.helpers.LogLog#debug()
The following examples show how to use
org.apache.log4j.helpers.LogLog#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: ShortSocketServer.java From cacheonix-core with GNU Lesser General Public License v2.1 | 7 votes |
public static void main(String args[]) throws Exception { int totalTests = 0; String prefix = null; if(args.length == 2) { totalTests = Integer.parseInt(args[0]); prefix = args[1]; } else { usage("Wrong number of arguments."); } LogLog.debug("Listening on port " + SocketServerTestCase.PORT); ServerSocket serverSocket = new ServerSocket(SocketServerTestCase.PORT); MDC.put("hostID", "shortSocketServer"); for(int i = 1; i <= totalTests; i++) { PropertyConfigurator.configure(prefix+i+".properties"); LogLog.debug("Waiting to accept a new client."); Socket socket = serverSocket.accept(); LogLog.debug("Connected to client at " + socket.getInetAddress()); LogLog.debug("Starting new socket node."); SocketNode sn = new SocketNode(socket, LogManager.getLoggerRepository()); Thread t = new Thread(sn); t.start(); t.join(); } }
Example 2
Source File: RocketmqLog4jAppender.java From DDMQ with Apache License 2.0 | 6 votes |
/** * When system exit,this method will be called to close resources */ public synchronized void close() { // The synchronized modifier avoids concurrent append and close operations if (this.closed) return; LogLog.debug("Closing RocketmqLog4jAppender [" + name + "]."); this.closed = true; try { ProducerInstance.getProducerInstance().removeAndClose(this.nameServerAddress, this.producerGroup); } catch (Exception e) { LogLog.error("Closing RocketmqLog4jAppender [" + name + "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage()); } // Help garbage collection producer = null; }
Example 3
Source File: DailyMaxRollingFileAppender.java From sailfish-core with Apache License 2.0 | 6 votes |
void printPeriodicity(int type) { switch (type) { case TOP_OF_MINUTE: LogLog.debug("Appender [" + name + "] to be rolled every minute."); break; case TOP_OF_HOUR: LogLog.debug("Appender [" + name + "] to be rolled on top of every hour."); break; case HALF_DAY: LogLog.debug("Appender [" + name + "] to be rolled at midday and midnight."); break; case TOP_OF_DAY: LogLog.debug("Appender [" + name + "] to be rolled at midnight."); break; case TOP_OF_WEEK: LogLog.debug("Appender [" + name + "] to be rolled at start of week."); break; case TOP_OF_MONTH: LogLog.debug("Appender [" + name + "] to be rolled at start of every month."); break; default: LogLog.warn("Unknown periodicity for appender [" + name + "]."); } }
Example 4
Source File: FallbackErrorHandler.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** Prints the message and the stack trace of the exception on <code>System.err</code>. */ public void error(String message, Exception e, int errorCode, LoggingEvent event) { LogLog.debug("FB: The following error reported: " + message, e); LogLog.debug("FB: INITIATING FALLBACK PROCEDURE."); if (loggers != null) { for(int i = 0; i < loggers.size(); i++) { Logger l = (Logger) loggers.elementAt(i); LogLog.debug("FB: Searching for ["+primary.getName()+"] in logger [" +l.getName() + "]."); LogLog.debug("FB: Replacing ["+primary.getName()+"] by [" + backup.getName() + "] in logger ["+ l.getName() +"]."); l.removeAppender(primary); LogLog.debug("FB: Adding appender ["+backup.getName()+"] to logger " + l.getName()); l.addAppender(backup); } } }
Example 5
Source File: RocketmqLog4jAppender.java From DDMQ with Apache License 2.0 | 6 votes |
/** * When system exit,this method will be called to close resources */ public synchronized void close() { // The synchronized modifier avoids concurrent append and close operations if (this.closed) return; LogLog.debug("Closing RocketmqLog4jAppender [" + name + "]."); this.closed = true; try { ProducerInstance.getProducerInstance().removeAndClose(this.nameServerAddress, this.producerGroup); } catch (Exception e) { LogLog.error("Closing RocketmqLog4jAppender [" + name + "] nameServerAddress:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage()); } // Help garbage collection producer = null; }
Example 6
Source File: IMAppender.java From olat with Apache License 2.0 | 6 votes |
/** * Close this IMAppender. Closing all resources used by the appender. A closed appender cannot be re-opened. */ @Override public synchronized void close() {// o_clusterOK by:fj if (this.closed) { return; } LogLog.debug("Closing appender [" + name + "]"); this.closed = true; // Closes the connection by setting presence to unavailable // then closing the stream to the XMPP server. if (con != null) { con.disconnect(); } // Help GC con = null; chats.clear(); chats = null; groupchat = null; }
Example 7
Source File: ExternallyRolledFileAppender.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
public void run() { while(!isInterrupted()) { try { ServerSocket serverSocket = new ServerSocket(port); while(true) { Socket socket = serverSocket.accept(); LogLog.debug("Connected to client at " + socket.getInetAddress()); new Thread(new HUPNode(socket, er)).start(); } } catch(Exception e) { e.printStackTrace(); } } }
Example 8
Source File: DailyMaxRollingFileAppender.java From tddl with Apache License 2.0 | 6 votes |
public void activateOptions() { super.activateOptions(); LogLog.debug("Max backup file kept: " + maxBackupIndex + "."); if (datePattern != null && fileName != null) { now.setTime(System.currentTimeMillis()); sdf = new SimpleDateFormat(datePattern); int type = computeCheckPeriod(); printPeriodicity(type); rpc.setType(type); File file = new File(fileName); scheduledFilename = fileName + sdf.format(new Date(file.lastModified())); } else { LogLog.error("Either File or DatePattern options are not set for appender [" + name + "]."); } }
Example 9
Source File: LazyFileAppender.java From swift-k with Apache License 2.0 | 6 votes |
/** * Override FileAppender.setFile to avoid creating an empty log file before * the code has a chance to customize the file name. */ public synchronized void setFile(String fileName, boolean append, boolean bufferedIO, int bufferSize) throws IOException { LogLog.debug("setFile called: " + fileName + ", " + append); if (this.qw != null) { return; } // set a stdout writer just in case reset(); Writer fw = createWriter(System.out); this.setQWForFiles(fw); this.fileName = fileName; this.fileAppend = append; this.bufferedIO = bufferedIO; this.bufferSize = bufferSize; LogLog.debug("setFile ended"); }
Example 10
Source File: RocketmqLog4jAppender.java From rocketmq with Apache License 2.0 | 5 votes |
public void activateOptions() { LogLog.debug("Getting initial context."); if (!checkEntryConditions()) { return; } try { producer = ProducerInstance.getProducerInstance().getInstance(nameServerAddress, producerGroup); } catch (Exception e) { LogLog.error("activateOptions nameserver:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage()); } }
Example 11
Source File: RocketmqLog4jAppender.java From DDMQ with Apache License 2.0 | 5 votes |
public void activateOptions() { LogLog.debug("Getting initial context."); if (!checkEntryConditions()) { return; } try { producer = ProducerInstance.getProducerInstance().getInstance(nameServerAddress, producerGroup); } catch (Exception e) { LogLog.error("activateOptions nameserver:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage()); } }
Example 12
Source File: MaxBackupIndexDailyRollingFileAppender.java From rebuild with GNU General Public License v3.0 | 5 votes |
@Override protected void subAppend(LoggingEvent event) { super.subAppend(event); long n = System.currentTimeMillis(); if (n >= lastCheck) { // 5 min long checkPeriod = 1000 * 60 * 5; lastCheck = n + checkPeriod; } else { return; } // unset if (maxBackupIndex <= 0) { return; } File file = new File(fileName); File[] logs = file.getParentFile().listFiles(new LogFileFilter(file.getName())); if (logs == null || maxBackupIndex >= logs.length) { return; } Arrays.sort(logs, new CompratorByLastModified()); for (int i = maxBackupIndex; i < logs.length; i++) { File log = logs[i]; if (log.exists()) { FileUtils.deleteQuietly(log); LogLog.debug("Deleted log file : " + log); } } }
Example 13
Source File: LogFileFilter.java From EdgeSim with MIT License | 5 votes |
public boolean accept(File file) { if(logName == null || file.isDirectory()){ return false; }else{ LogLog.debug(file.getName()); return file.getName().startsWith(logName); } }
Example 14
Source File: PropertyConfigurator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** Check the provided <code>Properties</code> object for a {@link org.apache.log4j.spi.LoggerFactory LoggerFactory} entry specified by {@link #LOGGER_FACTORY_KEY}. If such an entry exists, an attempt is made to create an instance using the default constructor. This instance is used for subsequent Category creations within this configurator. @see #parseCatsAndRenderers */ protected void configureLoggerFactory(Properties props) { String factoryClassName = OptionConverter.findAndSubst(LOGGER_FACTORY_KEY, props); if(factoryClassName != null) { LogLog.debug("Setting category factory to ["+factoryClassName+"]."); loggerFactory = (LoggerFactory) OptionConverter.instantiateByClassName(factoryClassName, LoggerFactory.class, loggerFactory); PropertySetter.setProperties(loggerFactory, props, FACTORY_PREFIX + "."); } }
Example 15
Source File: RocketmqLog4jAppender.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
public void activateOptions() { LogLog.debug("Getting initial context."); if (!checkEntryConditions()) { return; } try { producer = ProducerInstance.getProducerInstance().getInstance(nameServerAddress, producerGroup); } catch (Exception e) { LogLog.error("activateOptions nameserver:" + nameServerAddress + " group:" + producerGroup + " " + e.getMessage()); } }
Example 16
Source File: PropertyConfigurator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** Read configuration options from <code>properties</code>. See {@link #doConfigure(String, LoggerRepository)} for the expected format. */ public void doConfigure(Properties properties, LoggerRepository hierarchy) { String value = properties.getProperty(LogLog.DEBUG_KEY); if(value == null) { value = properties.getProperty("log4j.configDebug"); if(value != null) LogLog.warn("[log4j.configDebug] is deprecated. Use [log4j.debug] instead."); } if(value != null) { LogLog.setInternalDebugging(OptionConverter.toBoolean(value, true)); } // // if log4j.reset=true then // reset hierarchy String reset = properties.getProperty(RESET_KEY); if (reset != null && OptionConverter.toBoolean(reset, false)) { hierarchy.resetConfiguration(); } String thresholdStr = OptionConverter.findAndSubst(THRESHOLD_PREFIX, properties); if(thresholdStr != null) { hierarchy.setThreshold(OptionConverter.toLevel(thresholdStr, (Level) Level.ALL)); LogLog.debug("Hierarchy threshold set to ["+hierarchy.getThreshold()+"]."); } configureRootCategory(properties, hierarchy); configureLoggerFactory(properties); parseCatsAndRenderers(properties, hierarchy); LogLog.debug("Finished configuring."); // We don't want to hold references to appenders preventing their // garbage collection. registry.clear(); }
Example 17
Source File: FallbackErrorHandler.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
/** Set the backup appender. */ public void setBackupAppender(Appender backup) { LogLog.debug("FB: Setting backup appender to [" + backup.getName() + "]."); this.backup = backup; }
Example 18
Source File: DailyRollingFileAppender.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
/** Rollover the current file to a new file. */ void rollOver() throws IOException { /* Compute filename, but only if datePattern is specified */ if (datePattern == null) { errorHandler.error("Missing DatePattern option in rollOver()."); return; } String datedFilename = fileName+sdf.format(now); // It is too early to roll over because we are still within the // bounds of the current interval. Rollover will occur once the // next interval is reached. if (scheduledFilename.equals(datedFilename)) { return; } // close current file, and rename it to datedFilename this.closeFile(); File target = new File(scheduledFilename); if (target.exists()) { target.delete(); } File file = new File(fileName); boolean result = file.renameTo(target); if(result) { LogLog.debug(fileName +" -> "+ scheduledFilename); } else { LogLog.error("Failed to rename ["+fileName+"] to ["+scheduledFilename+"]."); } try { // This will also close the file. This is OK since multiple // close operations are safe. this.setFile(fileName, false, this.bufferedIO, this.bufferSize); } catch(IOException e) { errorHandler.error("setFile("+fileName+", false) call failed."); } scheduledFilename = datedFilename; }
Example 19
Source File: DOMConfigurator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
/** Used internally to parse the children of a category element. */ protected void parseChildrenOfLoggerElement(Element catElement, Logger cat, boolean isRoot) { PropertySetter propSetter = new PropertySetter(cat); // Remove all existing appenders from cat. They will be // reconstructed if need be. cat.removeAllAppenders(); NodeList children = catElement.getChildNodes(); final int length = children.getLength(); for (int loop = 0; loop < length; loop++) { Node currentNode = children.item(loop); if (currentNode.getNodeType() == Node.ELEMENT_NODE) { Element currentElement = (Element) currentNode; String tagName = currentElement.getTagName(); if (tagName.equals(APPENDER_REF_TAG)) { Element appenderRef = (Element) currentNode; Appender appender = findAppenderByReference(appenderRef); String refName = subst(appenderRef.getAttribute(REF_ATTR)); if(appender != null) LogLog.debug("Adding appender named ["+ refName+ "] to category ["+cat.getName()+"]."); else LogLog.debug("Appender named ["+ refName + "] not found."); cat.addAppender(appender); } else if(tagName.equals(LEVEL_TAG)) { parseLevel(currentElement, cat, isRoot); } else if(tagName.equals(PRIORITY_TAG)) { parseLevel(currentElement, cat, isRoot); } else if(tagName.equals(PARAM_TAG)) { setParameter(currentElement, propSetter); } else { quietParseUnrecognizedElement(cat, currentElement, props); } } } propSetter.activate(); }
Example 20
Source File: PropertyConfigurator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
/** This method must work for the root category as well. */ void parseCategory(Properties props, Logger logger, String optionKey, String loggerName, String value) { LogLog.debug("Parsing for [" +loggerName +"] with value=[" + value+"]."); // We must skip over ',' but not white space StringTokenizer st = new StringTokenizer(value, ","); // If value is not in the form ", appender.." or "", then we should set // the level of the loggeregory. if(!(value.startsWith(",") || value.equals(""))) { // just to be on the safe side... if(!st.hasMoreTokens()) return; String levelStr = st.nextToken(); LogLog.debug("Level token is [" + levelStr + "]."); // If the level value is inherited, set category level value to // null. We also check that the user has not specified inherited for the // root category. if(INHERITED.equalsIgnoreCase(levelStr) || NULL.equalsIgnoreCase(levelStr)) { if(loggerName.equals(INTERNAL_ROOT_NAME)) { LogLog.warn("The root logger cannot be set to null."); } else { logger.setLevel(null); } } else { logger.setLevel(OptionConverter.toLevel(levelStr, (Level) Level.DEBUG)); } LogLog.debug("Category " + loggerName + " set to " + logger.getLevel()); } // Begin by removing all existing appenders. logger.removeAllAppenders(); Appender appender; String appenderName; while(st.hasMoreTokens()) { appenderName = st.nextToken().trim(); if(appenderName == null || appenderName.equals(",")) continue; LogLog.debug("Parsing appender named \"" + appenderName +"\"."); appender = parseAppender(props, appenderName); if(appender != null) { logger.addAppender(appender); } } }