/** * Close all log files and remove handlers from loggers. */ public void closeLogFiles() { if (fileHandlers != null) { for (Logger l: fileHandlers.keySet()) { GenerationFileHandler gfh = (GenerationFileHandler)fileHandlers.get(l); gfh.close(); l.removeHandler(gfh); } } }
protected void rotateLogFiles(String generationSuffix, boolean mergeOld) throws IOException { for (Logger l : fileHandlers.keySet()) { GenerationFileHandler gfh = (GenerationFileHandler) fileHandlers.get(l); GenerationFileHandler newGfh = gfh.rotate(generationSuffix, "", mergeOld); if (gfh.shouldManifest()) { addToManifest((String) newGfh.getFilenameSeries().get(1), MANIFEST_LOG_FILE, newGfh.shouldManifest()); } l.removeHandler(gfh); l.addHandler(newGfh); fileHandlers.put(l, newGfh); } }
private void setupLogFile(Logger logger, String filename, Formatter f, boolean shouldManifest) throws IOException, SecurityException { logger.setLevel(Level.INFO); // set all standard loggers to INFO GenerationFileHandler fh = GenerationFileHandler.makeNew(filename, false, shouldManifest); fh.setFormatter(f); logger.addHandler(fh); addToManifest(filename, MANIFEST_LOG_FILE, shouldManifest); logger.setUseParentHandlers(false); this.fileHandlers.put(logger, fh); }
public GenerationFileHandler rotate(String storeSuffix, String activeSuffix, boolean mergeOld) throws IOException { close(); String filename = (String) filenameSeries.getFirst(); if (!filename.endsWith(activeSuffix)) { GenerationFileHandler newGfh = new GenerationFileHandler( filenameSeries, shouldManifest); newGfh.setFormatter(this.getFormatter()); return newGfh;
/** * Move the current file to a new filename with the storeSuffix in place * of the activeSuffix; continuing logging to a new file under the * original filename. * * @param storeSuffix Suffix to put in place of <code>activeSuffix</code> * @param activeSuffix Suffix to replace with <code>storeSuffix</code>. * @return GenerationFileHandler instance. * @throws IOException */ public GenerationFileHandler rotate(String storeSuffix, String activeSuffix) throws IOException { return rotate(storeSuffix, activeSuffix, false); }
/** * Constructor-helper that rather than clobbering any existing * file, moves it aside with a timestamp suffix. * * @param filename * @param append * @param shouldManifest * @return * @throws SecurityException * @throws IOException */ public static GenerationFileHandler makeNew(String filename, boolean append, boolean shouldManifest) throws SecurityException, IOException { FileUtils.moveAsideIfExists(new File(filename)); return new GenerationFileHandler(filename, append, shouldManifest); }
@Override public void publish(LogRecord record) { // when possible preformat outside synchronized superclass method // (our most involved UriProcessingFormatter can cache result) Formatter f = getFormatter(); if(!(f instanceof Preformatter)) { super.publish(record); } else { try { ((Preformatter)f).preformat(record); super.publish(record); } finally { ((Preformatter)f).clear(); } } } //
public GenerationFileHandler rotate(String storeSuffix, String activeSuffix, boolean mergeOld) throws IOException { close(); String filename = (String) filenameSeries.getFirst(); if (!filename.endsWith(activeSuffix)) { GenerationFileHandler newGfh = new GenerationFileHandler( filenameSeries, shouldManifest); newGfh.setFormatter(this.getFormatter()); return newGfh;
/** * Move the current file to a new filename with the storeSuffix in place * of the activeSuffix; continuing logging to a new file under the * original filename. * * @param storeSuffix Suffix to put in place of <code>activeSuffix</code> * @param activeSuffix Suffix to replace with <code>storeSuffix</code>. * @return GenerationFileHandler instance. * @throws IOException */ public GenerationFileHandler rotate(String storeSuffix, String activeSuffix) throws IOException { return rotate(storeSuffix, activeSuffix, false); }
/** * Constructor-helper that rather than clobbering any existing * file, moves it aside with a timestamp suffix. * * @param filename * @param append * @param shouldManifest * @return * @throws SecurityException * @throws IOException */ public static GenerationFileHandler makeNew(String filename, boolean append, boolean shouldManifest) throws SecurityException, IOException { FileUtils.moveAsideIfExists(new File(filename)); return new GenerationFileHandler(filename, append, shouldManifest); }
@Override public void publish(LogRecord record) { // when possible preformat outside synchronized superclass method // (our most involved UriProcessingFormatter can cache result) Formatter f = getFormatter(); if(!(f instanceof Preformatter)) { super.publish(record); } else { try { ((Preformatter)f).preformat(record); super.publish(record); } finally { ((Preformatter)f).clear(); } } } //
public GenerationFileHandler rotate(String storeSuffix, String activeSuffix, boolean mergeOld) throws IOException { close(); String filename = (String) filenameSeries.getFirst(); if (!filename.endsWith(activeSuffix)) { GenerationFileHandler newGfh = new GenerationFileHandler( filenameSeries, shouldManifest); newGfh.setFormatter(this.getFormatter()); return newGfh;
private void setupAlertLog(String logsPath) throws IOException { Logger logger = Logger.getLogger(LOGNAME_ALERTS + "." + logsPath); String filename = getAlertsLogPath().getFile().getAbsolutePath(); GenerationFileHandler fh = GenerationFileHandler.makeNew(filename, false, true); fh.setFormatter(new SimpleFormatter()); AlertThreadGroup.current().addLogger(logger); AlertHandler.ensureStaticInitialization(); logger.addHandler(fh); addToManifest(filename, MANIFEST_LOG_FILE, true); logger.setUseParentHandlers(false); this.fileHandlers.put(logger, fh); }
protected void rotateLogFiles(String generationSuffix, boolean mergeOld) throws IOException { for (Logger l : fileHandlers.keySet()) { GenerationFileHandler gfh = (GenerationFileHandler) fileHandlers.get(l); GenerationFileHandler newGfh = gfh.rotate(generationSuffix, "", mergeOld); if (gfh.shouldManifest()) { addToManifest((String) newGfh.getFilenameSeries().get(1), MANIFEST_LOG_FILE, newGfh.shouldManifest()); } l.removeHandler(gfh); l.addHandler(newGfh); fileHandlers.put(l, newGfh); } }
/** * Move the current file to a new filename with the storeSuffix in place * of the activeSuffix; continuing logging to a new file under the * original filename. * * @param storeSuffix Suffix to put in place of <code>activeSuffix</code> * @param activeSuffix Suffix to replace with <code>storeSuffix</code>. * @return GenerationFileHandler instance. * @throws IOException */ public GenerationFileHandler rotate(String storeSuffix, String activeSuffix) throws IOException { return rotate(storeSuffix, activeSuffix, false); }
/** * Close all log files and remove handlers from loggers. */ public void closeLogFiles() { if (fileHandlers != null) { for (Logger l: fileHandlers.keySet()) { GenerationFileHandler gfh = (GenerationFileHandler)fileHandlers.get(l); gfh.close(); l.removeHandler(gfh); } } }
/** * Constructor-helper that rather than clobbering any existing * file, moves it aside with a timestamp suffix. * * @param filename * @param append * @param shouldManifest * @return * @throws SecurityException * @throws IOException */ public static GenerationFileHandler makeNew(String filename, boolean append, boolean shouldManifest) throws SecurityException, IOException { FileUtils.moveAsideIfExists(new File(filename)); return new GenerationFileHandler(filename, append, shouldManifest); }
@Override public void publish(LogRecord record) { // when possible preformat outside synchronized superclass method // (our most involved UriProcessingFormatter can cache result) Formatter f = getFormatter(); if(!(f instanceof Preformatter)) { super.publish(record); } else { try { ((Preformatter)f).preformat(record); super.publish(record); } finally { ((Preformatter)f).clear(); } } } //
private void setupLogFile(Logger logger, String filename, Formatter f, boolean shouldManifest) throws IOException, SecurityException { logger.setLevel(Level.INFO); // set all standard loggers to INFO GenerationFileHandler fh = GenerationFileHandler.makeNew(filename, false, shouldManifest); fh.setFormatter(f); logger.addHandler(fh); addToManifest(filename, MANIFEST_LOG_FILE, shouldManifest); logger.setUseParentHandlers(false); this.fileHandlers.put(logger, fh); }
private void setupAlertLog(String logsPath) throws IOException { Logger logger = Logger.getLogger(LOGNAME_ALERTS + "." + logsPath); String filename = getAlertsLogPath().getFile().getAbsolutePath(); GenerationFileHandler fh = GenerationFileHandler.makeNew(filename, false, true); fh.setFormatter(new SimpleFormatter()); AlertThreadGroup.current().addLogger(logger); AlertHandler.ensureStaticInitialization(); logger.addHandler(fh); addToManifest(filename, MANIFEST_LOG_FILE, true); logger.setUseParentHandlers(false); this.fileHandlers.put(logger, fh); }