Search in sources :

Example 1 with JBossLoggingAccessLogReceiver

use of io.undertow.server.handlers.accesslog.JBossLoggingAccessLogReceiver in project wildfly by wildfly.

the class AccessLogService method start.

@Override
public void start(StartContext context) throws StartException {
    if (useServerLog) {
        logReceiver = new JBossLoggingAccessLogReceiver();
    } else {
        if (pathRelativeTo != null) {
            callbackHandle = pathManager.getValue().registerCallback(pathRelativeTo, PathManager.ReloadServerCallback.create(), PathManager.Event.UPDATED, PathManager.Event.REMOVED);
        }
        directory = Paths.get(pathManager.getValue().resolveRelativePathEntry(path, pathRelativeTo));
        if (!Files.exists(directory)) {
            try {
                Files.createDirectories(directory);
            } catch (IOException e) {
                throw UndertowLogger.ROOT_LOGGER.couldNotCreateLogDirectory(directory, e);
            }
        }
        try {
            DefaultAccessLogReceiver.Builder builder = DefaultAccessLogReceiver.builder().setLogWriteExecutor(worker.getValue()).setOutputDirectory(directory).setLogBaseName(filePrefix).setLogNameSuffix(fileSuffix).setRotate(rotate);
            if (extended) {
                builder.setLogFileHeaderGenerator(new ExtendedAccessLogParser.ExtendedAccessLogHeaderGenerator(pattern));
                extendedPattern = new ExtendedAccessLogParser(getClass().getClassLoader()).parse(pattern);
            } else {
                extendedPattern = null;
            }
            logReceiver = builder.build();
        } catch (IllegalStateException e) {
            throw new StartException(e);
        }
    }
    host.getValue().setAccessLogService(this);
}
Also used : ExtendedAccessLogParser(io.undertow.server.handlers.accesslog.ExtendedAccessLogParser) StartException(org.jboss.msc.service.StartException) IOException(java.io.IOException) DefaultAccessLogReceiver(io.undertow.server.handlers.accesslog.DefaultAccessLogReceiver) JBossLoggingAccessLogReceiver(io.undertow.server.handlers.accesslog.JBossLoggingAccessLogReceiver)

Aggregations

DefaultAccessLogReceiver (io.undertow.server.handlers.accesslog.DefaultAccessLogReceiver)1 ExtendedAccessLogParser (io.undertow.server.handlers.accesslog.ExtendedAccessLogParser)1 JBossLoggingAccessLogReceiver (io.undertow.server.handlers.accesslog.JBossLoggingAccessLogReceiver)1 IOException (java.io.IOException)1 StartException (org.jboss.msc.service.StartException)1