use of java.util.logging.SimpleFormatter in project malmo by Microsoft.
the class TCPSocketHelper method setLogging.
static void setLogging(boolean log) {
logging = log;
if (log == true && filehandler == null) {
try {
filehandler = new FileHandler("TCPLog.txt");
filehandler.setFormatter(new SimpleFormatter());
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.addHandler(filehandler);
}
}
use of java.util.logging.SimpleFormatter in project jreversepro by akkumar.
the class CustomLoggerFactory method createLogger.
public static Logger createLogger() {
final Logger logger = Logger.getLogger("JReversePro");
final SimpleFormatter formatter = new SimpleFormatter();
final StreamHandler handler = new StreamHandler(System.out, formatter);
logger.addHandler(handler);
logger.setLevel(Level.FINER);
return logger;
}
use of java.util.logging.SimpleFormatter in project heron by twitter.
the class LoggingHelper method getFileHandler.
/**
* Initialize a <tt>FileHandler</tt> to write to a set of files
* with optional append. When (approximately) the given limit has
* been written to one file, another file will be opened. The
* output will cycle through a set of count files.
* The pattern of file name should be: ${processId}.log.index
* <p>
* The <tt>FileHandler</tt> is configured based on <tt>LogManager</tt>
* properties (or their default values) except that the given pattern
* argument is used as the filename pattern, the file limit is
* set to the limit argument, and the file count is set to the
* given count argument, and the append mode is set to the given
* <tt>append</tt> argument.
* <p>
* The count must be at least 1.
*
* @param limit the maximum number of bytes to write to any one file
* @param count the number of files to use
* @param append specifies append mode
* @throws IOException if there are IO problems opening the files.
* @throws SecurityException if a security manager exists and if
* the caller does not have <tt>LoggingPermission("control")</tt>.
* @throws IllegalArgumentException if {@code limit < 0}, or {@code count < 1}.
* @throws IllegalArgumentException if pattern is an empty string
*/
public static FileHandler getFileHandler(String processId, String loggingDir, boolean append, int limit, int count) throws IOException, SecurityException {
String pattern = loggingDir + "/" + processId + ".log.%g";
FileHandler fileHandler = new FileHandler(pattern, limit, count, append);
fileHandler.setFormatter(new SimpleFormatter());
fileHandler.setEncoding("UTF-8");
return fileHandler;
}
use of java.util.logging.SimpleFormatter in project CoreNLP by stanfordnlp.
the class MachineReading method setConsoleLevel.
public static void setConsoleLevel(Level level) {
// get the top Logger:
Logger topLogger = java.util.logging.Logger.getLogger("");
// Handler for console (reuse it if it already exists)
Handler consoleHandler = null;
// see if there is already a console handler
for (Handler handler : topLogger.getHandlers()) {
if (handler instanceof ConsoleHandler) {
// found the console handler
consoleHandler = handler;
break;
}
}
if (consoleHandler == null) {
// there was no console handler found, create a new one
consoleHandler = new ConsoleHandler();
topLogger.addHandler(consoleHandler);
}
// set the console handler level:
consoleHandler.setLevel(level);
consoleHandler.setFormatter(new SimpleFormatter());
}
use of java.util.logging.SimpleFormatter in project okhttp by square.
the class Main method enableHttp2FrameLogging.
private static void enableHttp2FrameLogging() {
frameLogger = Logger.getLogger(Http2.class.getName());
frameLogger.setLevel(Level.FINE);
ConsoleHandler handler = new ConsoleHandler();
handler.setLevel(Level.FINE);
handler.setFormatter(new SimpleFormatter() {
@Override
public String format(LogRecord record) {
return Util.format("%s%n", record.getMessage());
}
});
frameLogger.addHandler(handler);
}
Aggregations