本文整理汇总了Java中org.pmw.tinylog.Configurator类的典型用法代码示例。如果您正苦于以下问题:Java Configurator类的具体用法?Java Configurator怎么用?Java Configurator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Configurator类属于org.pmw.tinylog包,在下文中一共展示了Configurator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listExamples
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
public List<File> listExamples(final File folder) {
Configurator.defaultConfig()
.writer(new FileWriter(logFile))
.level(Level.INFO)
.activate();
Logger.error("ENTER LIST EXAMPLES");
List<File> directories = new ArrayList<File> ();
for (final File fileEntry : folder.listFiles()) {
Logger.error("Listando"+ fileEntry.getAbsolutePath());
if (fileEntry.isDirectory()) {
directories.add(fileEntry);
}
}
Logger.error("EXIT LIST EXAMPLES");
return directories;
}
示例2: createInstance
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
public static void createInstance(boolean fileLog, boolean consoleLog) {
if (!fileLog && !consoleLog) {
Log.setInstance(new DeactivatedLog());
return;
}
final Configurator logConfigurator = Configurator.defaultConfig();
logConfigurator.removeAllWriters();
if (fileLog) {
logConfigurator.addWriter(new FileWriter("uaiMockServer.log"));
}
if (consoleLog) {
logConfigurator.addWriter(new ConsoleWriter());
}
logConfigurator.formatPattern("[uaiMockServer] {date:yyyy-MM-dd HH:mm:ss} [{thread}] {level}: {message}");
logConfigurator.activate();
Log.setInstance(new ActivatedLog());
}
示例3: testLoggingFromProperties
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
@Test
public void testLoggingFromProperties() throws IOException {
Configurator.fromResource("gelf-writer.properties").activate();
@SuppressWarnings("all")
final RuntimeException exception = new RuntimeException("BOOM!");
exception.fillInStackTrace();
Logger.trace("Test");
Logger.trace(exception, "Test");
Logger.trace("Test {}", 1234);
Logger.debug("Test");
Logger.debug(exception, "Test");
Logger.debug("Test {}", 1234);
Logger.info("Test");
Logger.info(exception, "Test");
Logger.info("Test {}", 1234);
Logger.warn("Test");
Logger.warn(exception, "Test");
Logger.warn("Test {}", 1234);
Logger.error("Test");
Logger.error(exception, "Test");
Logger.error("Test {}", 1234);
}
示例4: AccessLog
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
/**
* In the constructor the callbacks and the logging configuration are initialized.
*
* @param callbackRegistry injected HiveMQ Callback Registry
*/
@Inject
public AccessLog(CallbackRegistry callbackRegistry) {
try {
Configurator.defaultConfig()
.writer(new RollingFileWriter(new File(PathUtils.getHiveMQLogFolder(), "hivemq-access.log").getAbsolutePath(), 10, new TimestampLabeller("yyyMMdd"), new DailyPolicy()))
.level(LoggingLevel.INFO)
.formatPattern("{date:yyyy-MM-dd HH:mm:ss} {message}")
.activate();
callbackRegistry.addCallback(onConnectCallback());
callbackRegistry.addCallback(disconnectCallback());
callbackRegistry.addCallback(onSubscribe());
callbackRegistry.addCallback(onPublish());
callbackRegistry.addCallback(onUnsubscribeCallback());
} catch (IOException e) {
log.error("An error occured while configuring the AccessLogger. No Callbacks registered", e);
}
}
示例5: setupBatchLogConfig
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
private static void setupBatchLogConfig() {
Configurator.defaultConfig()
.writer(new RollingFileWriter(PropertiesRepo.get(Constants.Settings.LOG_PATH) + File.separator + "data-import.log", 10, new CountLabeler(), new SizePolicy(1024 * 1024 * 100)))
//.addWriter(new ConsoleWriter())
.level(Level.valueOf(PropertiesRepo.get(Constants.Settings.LOG_LEVEL)))
.formatPattern(PropertiesRepo.get(Constants.Settings.LOG_PATTERN))
.activate();
}
示例6: setupEngineLogConfig
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
private static void setupEngineLogConfig() {
Configurator.defaultConfig()
.writer(new RollingFileWriter(PropertiesRepo.get(Constants.Settings.LOG_PATH) + File.separator + "matching-engine.log", 10, new CountLabeler(), new SizePolicy(1024 * 1024 * 100)))
//.addWriter(new ConsoleWriter())
.level(Level.valueOf(PropertiesRepo.get(Constants.Settings.LOG_LEVEL)))
.formatPattern(PropertiesRepo.get(Constants.Settings.LOG_PATTERN))
.activate();
}
示例7: init
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
public void init(String outputDir, RunnerTestResults runnerTestResults, File chromeExecutable) {
this.runnerTestResults = runnerTestResults;
this.chromeExecutable = chromeExecutable;
this.outputDir = new File(outputDir);
this.outputDir.mkdirs();
Configurator.defaultConfig()
.writer(new FileWriter(new File(this.outputDir, "log.txt").getAbsolutePath()))
.level(Level.INFO)
.activate();
}
示例8: testClose
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
@Test
public void testClose() throws Exception {
final GelfWriter gelfWriter = new GelfWriter();
Configurator.defaultConfig()
.writer(gelfWriter)
.level(Level.INFO)
.activate();
gelfWriter.close();
}
示例9: testLogging
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
@Test
public void testLogging() {
Configurator.defaultConfig()
.writer(new GelfWriter("localhost"))
.addWriter(new ConsoleWriter())
.level(Level.TRACE)
.activate();
@SuppressWarnings("all")
final RuntimeException exception = new RuntimeException("BOOM!");
exception.fillInStackTrace();
Logger.trace("Test");
Logger.trace(exception, "Test");
Logger.trace("Test {}", 1234);
Logger.debug("Test");
Logger.debug(exception, "Test");
Logger.debug("Test {}", 1234);
Logger.info("Test");
Logger.info(exception, "Test");
Logger.info("Test {}", 1234);
Logger.warn("Test");
Logger.warn(exception, "Test");
Logger.warn("Test {}", 1234);
Logger.error("Test");
Logger.error(exception, "Test");
Logger.error("Test {}", 1234);
}
示例10: main
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Configurator.defaultConfig()
.writer(new FileWriter("poemstarlog.txt"))
.level(Level.INFO)
.activate();
MainJDialog dlg = new MainJDialog(null, true);
dlg.setVisible(true);
}
示例11: configureLog
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
private static void configureLog() {
Configurator.defaultConfig().writer(new org.pmw.tinylog.writers.FileWriter(LOG_FILE))
.level(Level.INFO).activate();
}
示例12: getExamples
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
public List<Example> getExamples(){
Configurator.defaultConfig()
.writer(new FileWriter(logFile))
.level(Level.INFO)
.activate();
Logger.error("ENTER GET EXAMPLES");
Logger.error("Examples folder src: "+baseDir + "examples");
// Cleaning up:
String outputFromClean = executeCommand("rm -rf "+baseDir + "examples/"+"CUSTOM_*");
final File examplesFolder = new File(baseDir + "examples");
List<File> examplesDirectories = listExamples(examplesFolder);
Logger.error("Obtengo: "+ examplesDirectories.size() + " directorios");
List<Example> examples = new ArrayList<Example>();
for (final File exampleDirectory : examplesDirectories) {
Logger.error("Procesando: "+ exampleDirectory.getAbsolutePath());
Example example1 = new Example();
ArrayList<JavaFile> files = new ArrayList<JavaFile>();
// TODO Important!!! the examples must use "jheaptest" as package
Logger.error("Leyendo ficheros java de "+ exampleDirectory.getAbsolutePath()+"/src/jheaptest");
List<File> exampleFiles = listExampleFiles(new File(exampleDirectory.getAbsolutePath()+"/src/jheaptest"));
for (final File exampleFile : exampleFiles){
Logger.error("Fichero: "+ exampleFile.getAbsolutePath());
JavaFile file1 = new JavaFile(exampleFile.getName(), readFile(exampleFile.getAbsolutePath()));
files.add(file1);
}
example1.setFiles(files);
Logger.error("Buscando Input en "+ exampleDirectory.getAbsolutePath()+"/input");
example1.setInput(readFile(exampleDirectory.getAbsolutePath()+"/input"));
example1.setReadme(readFile(exampleDirectory.getAbsolutePath()+"/README"));
example1.setName(exampleDirectory.getName());
// looking for vars
example1.setVars(readVars(exampleDirectory.getAbsolutePath()+"/vars"));
examples.add(example1);
}
Logger.error("END GET EXAMPLES");
return examples;
}
示例13: main
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Get current Timestamp and Setup logger.
long timeInNanos = System.nanoTime();
String timeStamp = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss").format(new Date());
timeStamp += "." + ((int) (timeInNanos % 1000000000 / 100));
// Program start.
processArguments(args);
G.modelInstanceName = timeStamp;
G.outputDir = G.ns.getString("exec_dir") + "/" + timeStamp;
// Create Directory
Path dir = Paths.get(G.outputDir);
Files.createDirectories(dir);
System.out.println("------\nFLAGS\n------");
System.out.println("train-file: " + trainfile);
System.out.println("dev-file: " + valfile);
System.out.println("test-file: " + testfile);
System.out.println("hyper-parameter: " + HyperParameter.getInstance());
System.out.println("------\n");
Configurator.defaultConfig().writer(new FileWriter(G.outputDir + "/result.log"))
.level(Level.INFO).formatPattern("{level}\t{date}\t\t{message}").activate();
Logger.info(HyperParameter.getInstance());
Logger.info(trainfile + "\n");
DepPipe pipe = new DepPipe();
DepParserLauncher dp = null;
if (savedModel == null) {
DepInstance[] trainingData = pipe.createInstances(trainfile);
pipe.createAlphabet(trainingData);
dp = new DepParserLauncher(pipe);
int numFeats = pipe.featAlphabet.size();
int numReconsParentDim = dp.params.reconsParentAlphabet.size();
int numReconsChildDim = dp.params.reconsChildAlphabet.size();
System.out.println("Num Feats: " + numFeats);
System.out.println("Size of ReconsParent: " + numReconsParentDim);
System.out.println("Size of ReconsChild: " + numReconsChildDim);
// Training...
dp.train(trainingData);
} else {
dp = new DepParserLauncher(pipe);
dp.loadModel(savedModel);
}
// check dev accuracy.
if (valfile != null) {
dp.evaluatePerformance("Val", valfile, "10");
}
// check test accuracy.
if (testfile != null) {
dp.evaluatePerformance("Test", testfile, "10");
dp.evaluatePerformance("Test", testfile, "all");
}
dp.saveModel();
}
示例14: configTinylog
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
private static void configTinylog() {
Configurator.currentConfig()
.addWriter(new RollingFileWriter(LOG_FILE, 4, new SizePolicy(52428800)))
.formatPattern(LOGGING_FORMAT)
.activate();
}
示例15: init
import org.pmw.tinylog.Configurator; //导入依赖的package包/类
@Autowired
private void init() throws IOException {
File f = File.createTempFile("tinylog_conf", ".txt");
FileOutputStream fos = new FileOutputStream(f);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
try {
String writer = env.getProperty("tinylog.writer");
bw.write("tinylog.writer = " + writer);
bw.newLine();
/*String fileName = env.getProperty("tinylog.writer.filename");
bw.write("tinylog.writer.filename = " + fileName);
bw.newLine();
String buffered = env.getProperty("tinylog.writer.buffered");
bw.write("tinylog.writer.buffered = " + buffered);
bw.newLine();
String append = env.getProperty("tinylog.writer.append");
bw.write("tinylog.writer.append = " + append);
bw.newLine();*/
String level = env.getProperty("tinylog.level");
bw.write("tinylog.level = " + level);
bw.newLine();
String writerUrl = env.getProperty("tinylog.writer.url");
bw.write("tinylog.writer.url = " + writerUrl);
bw.newLine();
String writerTable = env.getProperty("tinylog.writer.table");
bw.write("tinylog.writer.table = " + writerTable);
bw.newLine();
String writerColumns = env.getProperty("tinylog.writer.columns");
bw.write("tinylog.writer.columns = " + writerColumns);
bw.newLine();
String writerValues = env.getProperty("tinylog.writer.values");
bw.write("tinylog.writer.values = " + writerValues);
bw.newLine();
String writerBatch = env.getProperty("tinylog.writer.batch");
bw.write("tinylog.writer.batch = " + writerBatch);
bw.newLine();
String writerUsername = env.getProperty("tinylog.writer.username");
bw.write("tinylog.writer.username = " + writerUsername);
bw.newLine();
String writerPassword = env.getProperty("tinylog.writer.password");
bw.write("tinylog.writer.password = " + writerPassword);
bw.newLine();
String writingThread = env.getProperty("tinylog.writingthread");
bw.write("tinylog.writingthread = " + writingThread);
bw.newLine();
String wTObserve = env.getProperty("tinylog.writingthread.observe");
bw.write("tinylog.writingthread.observe = " + wTObserve);
bw.newLine();
String wTPriority = env.getProperty("tinylog.writingthread.priority");
bw.write("writingthread.priority = " + wTPriority);
} catch (Exception e) {
e.printStackTrace();
} finally {
bw.close();
}
Configurator.fromFile(f).activate();
}