Search in sources :

Example 1 with ExtLogRecord

use of org.jboss.logmanager.ExtLogRecord in project quarkus-logging-logback by quarkiverse.

the class LogbackRecorder method createHandler.

public RuntimeValue<Optional<Handler>> createHandler() {
    started = true;
    for (DelayedStart i : DELAYED_START_HANDLERS) {
        i.doQuarkusDelayedStart();
    }
    DELAYED_START_HANDLERS.clear();
    return new RuntimeValue<>(Optional.of(new ExtHandler() {

        @Override
        public final void doPublish(final ExtLogRecord record) {
            if (defaultLoggerContext == null) {
                return;
            }
            Logger logger = defaultLoggerContext.getLogger(record.getLoggerName());
            logger.callAppenders(new LoggingEventWrapper(record, getFormatter()));
        }

        @Override
        public void flush() {
        }

        @Override
        public void close() throws SecurityException {
        }
    }));
}
Also used : ExtHandler(org.jboss.logmanager.ExtHandler) ExtLogRecord(org.jboss.logmanager.ExtLogRecord) RuntimeValue(io.quarkus.runtime.RuntimeValue) Logger(ch.qos.logback.classic.Logger)

Example 2 with ExtLogRecord

use of org.jboss.logmanager.ExtLogRecord in project wildfly-core by wildfly.

the class SyslogAuditLogHandler method writeLogItem.

@Override
void writeLogItem(String formattedItem) throws IOException {
    boolean reconnect = isReconnect();
    if (!reconnect) {
        handler.publish(new ExtLogRecord(Level.WARN, formattedItem, SyslogAuditLogHandler.class.getName()));
        errorManager.getAndThrowError();
    } else {
        ControllerLogger.MGMT_OP_LOGGER.attemptingReconnectToSyslog(name, reconnectTimeout);
        try {
            // establish a new connection
            if (!connected) {
                stop();
                initialize();
            }
            handler.publish(new ExtLogRecord(Level.WARN, formattedItem, SyslogAuditLogHandler.class.getName()));
            errorManager.getAndThrowError();
            lastErrorTime = -1;
        } catch (Exception e) {
            // A failure has occurred and initialization should be reattempted
            connected = false;
            lastErrorTime = System.currentTimeMillis();
            errorManager.throwAsIoOrRuntimeException(e);
        }
    }
}
Also used : ExtLogRecord(org.jboss.logmanager.ExtLogRecord) PortUnreachableException(java.net.PortUnreachableException) IOException(java.io.IOException)

Aggregations

ExtLogRecord (org.jboss.logmanager.ExtLogRecord)2 Logger (ch.qos.logback.classic.Logger)1 RuntimeValue (io.quarkus.runtime.RuntimeValue)1 IOException (java.io.IOException)1 PortUnreachableException (java.net.PortUnreachableException)1 ExtHandler (org.jboss.logmanager.ExtHandler)1