@Override public void close() { if (closed) return; closed = true; // TODO Auto-generated method stub super.close(); }
public void publish(LogRecord record) { if (!isLoggable(record)) { return; closeWriter(); date = tsDate; openWriter(); result = getFormatter().format(record); } catch (Exception e) { reportError(null, e, ErrorManager.FORMAT_FAILURE); return; reportError("FileHandler is closed or not yet initialized, unable to log ["+result+"]", null, ErrorManager.WRITE_FAILURE); reportError(null, e, ErrorManager.WRITE_FAILURE); return;
public FileHandler(String directory, String prefix, String suffix) { this.directory = directory; this.prefix = prefix; this.suffix = suffix; configure(); openWriter(); }
protected void closeWriter() { writerLock.writeLock().lock(); try { if (writer == null) return; writer.write(getFormatter().getTail(this)); writer.flush(); writer.close(); writer = null; date = ""; } catch (Exception e) { reportError(null, e, ErrorManager.CLOSE_FAILURE); } finally { writerLock.writeLock().unlock(); } }
rotatable = Boolean.parseBoolean(getProperty(className + ".rotatable", "true")); if (directory == null) directory = getProperty(className + ".directory", "logs"); if (prefix == null) prefix = getProperty(className + ".prefix", "juli."); if (suffix == null) suffix = getProperty(className + ".suffix", ".log"); String sBufferSize = getProperty(className + ".bufferSize", String.valueOf(bufferSize)); try { bufferSize = Integer.parseInt(sBufferSize); String encoding = getProperty(className + ".encoding", null); if (encoding != null && encoding.length() > 0) { try { setEncoding(encoding); } catch (UnsupportedEncodingException ex) { setLevel(Level.parse(getProperty(className + ".level", "" + Level.ALL))); String filterName = getProperty(className + ".filter", null); if (filterName != null) { try { setFilter((Filter) cl.loadClass(filterName).newInstance()); } catch (Exception e) { String formatterName = getProperty(className + ".formatter", null); if (formatterName != null) { try { setFormatter((Formatter) cl.loadClass(formatterName).newInstance());
reportError("Unable to create [" + dir + "]", null, ErrorManager.OPEN_FAILURE); writer = null; File parent = pathname.getParentFile(); if (!parent.mkdirs() && !parent.isDirectory()) { reportError("Unable to create [" + parent + "]", null, ErrorManager.OPEN_FAILURE); writer = null; return; String encoding = getEncoding(); FileOutputStream fos = new FileOutputStream(pathname, true); OutputStream os = bufferSize>0?new BufferedOutputStream(fos,bufferSize):fos; (encoding != null) ? new OutputStreamWriter(os, encoding) : new OutputStreamWriter(os), false); writer.write(getFormatter().getHead(this)); } catch (Exception e) { reportError(null, e, ErrorManager.OPEN_FAILURE); writer = null; } finally {
public FileHandler(String directory, String prefix, String suffix, Integer maxDays, Boolean rotatable, Integer bufferSize) { this.directory = directory; this.prefix = prefix; this.suffix = suffix; this.maxDays = maxDays; this.rotatable = rotatable; this.bufferSize = bufferSize; configure(); openWriter(); clean(); }
/** * Close the currently open log file (if any). */ @Override public void close() { closeWriter(); }
@Override protected void open() { if(!closed) return; closed = false; // TODO Auto-generated method stub super.open(); }
/** * Open the new log file for the date specified by <code>date</code>. */ protected void open() { openWriter(); }
protected void publishInternal(LogRecord record) { super.publish(record); }
rotatable = Boolean.parseBoolean(getProperty(className + ".rotatable", "true")); if (directory == null) directory = getProperty(className + ".directory", "logs"); if (prefix == null) prefix = getProperty(className + ".prefix", "juli."); if (suffix == null) suffix = getProperty(className + ".suffix", ".log"); String sBufferSize = getProperty(className + ".bufferSize", String.valueOf(bufferSize)); try { bufferSize = Integer.parseInt(sBufferSize); String encoding = getProperty(className + ".encoding", null); if (encoding != null && encoding.length() > 0) { try { setEncoding(encoding); } catch (UnsupportedEncodingException ex) { setLevel(Level.parse(getProperty(className + ".level", "" + Level.ALL))); String filterName = getProperty(className + ".filter", null); if (filterName != null) { try { setFilter((Filter) cl.loadClass(filterName).newInstance()); } catch (Exception e) { String formatterName = getProperty(className + ".formatter", null); if (formatterName != null) { try { setFormatter((Formatter) cl.loadClass(formatterName).newInstance());
protected void openWriter() { // Create the directory if necessary File dir = new File(directory); dir.mkdirs(); // Open the current log file writerLock.writeLock().lock(); try { String pathname = dir.getAbsolutePath() + File.separator + prefix + (rotatable ? date : "") + suffix; String encoding = getEncoding(); FileOutputStream fos = new FileOutputStream(pathname, true); OutputStream os = bufferSize>0?new BufferedOutputStream(fos,bufferSize):fos; writer = new PrintWriter( (encoding != null) ? new OutputStreamWriter(os, encoding) : new OutputStreamWriter(os), false); writer.write(getFormatter().getHead(this)); } catch (Exception e) { reportError(null, e, ErrorManager.OPEN_FAILURE); writer = null; } finally { writerLock.writeLock().unlock(); } }
protected void closeWriter() { writerLock.writeLock().lock(); try { if (writer == null) return; writer.write(getFormatter().getTail(this)); writer.flush(); writer.close(); writer = null; date = ""; } catch (Exception e) { reportError(null, e, ErrorManager.CLOSE_FAILURE); } finally { writerLock.writeLock().unlock(); } }
public FileHandler(String directory, String prefix, String suffix, int maxDays) { this.directory = directory; this.prefix = prefix; this.suffix = suffix; this.maxDays = maxDays; configure(); openWriter(); clean(); }
/** * Close the currently open log file (if any). */ @Override public void close() { closeWriter(); }
@Override protected void open() { if(!closed) return; closed = false; // TODO Auto-generated method stub super.open(); }
/** * Open the new log file for the date specified by <code>date</code>. */ protected void open() { openWriter(); }
protected void publishInternal(LogRecord record) { super.publish(record); }
rotatable = Boolean.parseBoolean(getProperty(className + ".rotatable", "true")); if (directory == null) directory = getProperty(className + ".directory", "logs"); if (prefix == null) prefix = getProperty(className + ".prefix", "juli."); if (suffix == null) suffix = getProperty(className + ".suffix", ".log"); String sBufferSize = getProperty(className + ".bufferSize", String.valueOf(bufferSize)); try { bufferSize = Integer.parseInt(sBufferSize); String encoding = getProperty(className + ".encoding", null); if (encoding != null && encoding.length() > 0) { try { setEncoding(encoding); } catch (UnsupportedEncodingException ex) { setLevel(Level.parse(getProperty(className + ".level", "" + Level.ALL))); String filterName = getProperty(className + ".filter", null); if (filterName != null) { try { setFilter((Filter) cl.loadClass(filterName).newInstance()); } catch (Exception e) { String formatterName = getProperty(className + ".formatter", null); if (formatterName != null) { try { setFormatter((Formatter) cl.loadClass(formatterName).newInstance());