Search in sources :

Example 1 with RollingFileWriter

use of org.pmw.tinylog.writers.RollingFileWriter in project openpnp by openpnp.

the class Main method configureLogging.

private static void configureLogging(File configurationDirectory) {
    File logDirectory = new File(configurationDirectory, "log");
    File logFile = new File(logDirectory, "OpenPnP.log");
    Configurator.currentConfig().writer(new RollingFileWriter(logFile.getAbsolutePath(), 100)).addWriter(new ConsoleWriter(System.out, System.err)).activate();
    Configurator.currentConfig().formatPattern("{date:yyyy-MM-dd HH:mm:ss.SSS} {class_name} {level}: {message}").activate();
    // Redirect the stdout and stderr to the LogPanel
    SystemLogger out = new SystemLogger(System.out, Level.INFO);
    SystemLogger err = new SystemLogger(System.err, Level.ERROR);
    System.setOut(out);
    System.setErr(err);
}
Also used : SystemLogger(org.openpnp.logging.SystemLogger) ConsoleWriter(org.openpnp.logging.ConsoleWriter) File(java.io.File) RollingFileWriter(org.pmw.tinylog.writers.RollingFileWriter)

Example 2 with RollingFileWriter

use of org.pmw.tinylog.writers.RollingFileWriter in project liferay-imex by jpdacunha.

the class ImexExecutionReportServiceImpl method initializeLogger.

private void initializeLogger(String logsPath) {
    if (configurator == null) {
        _log.debug("Initializing logger ...");
        configurator = Configurator.defaultConfig();
        configurator.level(Level.DEBUG);
        configurator.formatPattern("{date:yyyy-MM-dd HH:mm:ss} {level} [{thread}] [{context:" + ImexExecutionReportService.IDENTIFIER_KEY + "}] : {message}");
        if (_log.isDebugEnabled()) {
            _log.debug("IMEX output log path : " + logsPath);
        }
        RollingFileWriter writer = new RollingFileWriter(logsPath + "/" + LOG_FILE_NAME, 3, new TimestampLabeler("yyyy-MM-dd"), new DailyPolicy());
        configurator.addWriter(writer);
        configurator.activate();
        _log.debug("Done.");
    }
    if (this.displayInLiferayLogs == null) {
        ImexProperties coreConfig = new ImexProperties();
        configurationService.loadCoreConfiguration(coreConfig);
        this.displayInLiferayLogs = GetterUtil.getBoolean(coreConfig.getProperties().get(ImExCorePropsKeys.DISPLAY_EXECUTION_IN_LIFERAY_LOGS));
    }
}
Also used : TimestampLabeler(org.pmw.tinylog.labelers.TimestampLabeler) DailyPolicy(org.pmw.tinylog.policies.DailyPolicy) ImexProperties(com.liferay.imex.core.api.configuration.model.ImexProperties) RollingFileWriter(org.pmw.tinylog.writers.RollingFileWriter)

Example 3 with RollingFileWriter

use of org.pmw.tinylog.writers.RollingFileWriter in project trackworktime by mathisdt.

the class Basics method initTinyLog.

public void initTinyLog() {
    String threadToObserve = Thread.currentThread().getName();
    Configurator.defaultConfig().writer(new RollingFileWriter(getCurrentLogFile().getPath(), 2, false, new CountLabeler(), new DailyPolicy()), Level.DEBUG, "{date:yyyy-MM-dd HH:mm:ss} {{level}|min-size=5} {class_name}.{method} - {message}").addWriter(new LogcatWriter("trackworktime"), Level.DEBUG, "{message}").writingThread(threadToObserve, 1).activate();
    Logger.info("logger initialized - writing thread observes \"{}\"", threadToObserve);
}
Also used : DailyPolicy(org.pmw.tinylog.policies.DailyPolicy) LogcatWriter(org.pmw.tinylog.writers.LogcatWriter) RollingFileWriter(org.pmw.tinylog.writers.RollingFileWriter) CountLabeler(org.pmw.tinylog.labelers.CountLabeler)

Aggregations

RollingFileWriter (org.pmw.tinylog.writers.RollingFileWriter)3 DailyPolicy (org.pmw.tinylog.policies.DailyPolicy)2 ImexProperties (com.liferay.imex.core.api.configuration.model.ImexProperties)1 File (java.io.File)1 ConsoleWriter (org.openpnp.logging.ConsoleWriter)1 SystemLogger (org.openpnp.logging.SystemLogger)1 CountLabeler (org.pmw.tinylog.labelers.CountLabeler)1 TimestampLabeler (org.pmw.tinylog.labelers.TimestampLabeler)1 LogcatWriter (org.pmw.tinylog.writers.LogcatWriter)1