Search in sources :

Example 1 with VersionInfo

use of org.glassfish.api.VersionInfo in project Payara by payara.

the class JSONLogFormatter method getProductId.

/**
 * Payara can override this to specify product version.
 * @return The string value of the product id.
 */
protected String getProductId() {
    if (habitat != null) {
        VersionInfo version = habitat.getService(VersionInfo.class);
        if (productId.isEmpty() && version != null) {
            StringBuilder builder = new StringBuilder();
            builder.append(version.getAbbreviatedProductName());
            builder.append(' ');
            builder.append(version.getVersionPrefix());
            builder.append(version.getMajorVersion());
            builder.append('.');
            builder.append(version.getMinorVersion());
            productId = builder.toString();
        }
    }
    return productId;
}
Also used : VersionInfo(org.glassfish.api.VersionInfo)

Example 2 with VersionInfo

use of org.glassfish.api.VersionInfo in project Payara by payara.

the class UniformLogFormatter method getProductId.

/**
 * GlassFish can override to specify their product version
 */
protected String getProductId() {
    if (habitat != null) {
        VersionInfo versionInfo = habitat.getService(VersionInfo.class);
        if (productId.isEmpty() && versionInfo != null) {
            StringBuilder sb = new StringBuilder();
            sb.append(versionInfo.getAbbreviatedProductName());
            sb.append(' ');
            sb.append(versionInfo.getVersionPrefix());
            sb.append(versionInfo.getMajorVersion());
            sb.append('.');
            sb.append(versionInfo.getMinorVersion());
            productId = sb.toString();
        }
    }
    return productId;
}
Also used : VersionInfo(org.glassfish.api.VersionInfo)

Example 3 with VersionInfo

use of org.glassfish.api.VersionInfo in project Payara by payara.

the class LoggingExclusionTest method initializeLoggingTest.

private void initializeLoggingTest(String excludeFields) throws Exception {
    Globals.setDefaultHabitat(serviceLocatorMock);
    VersionInfo versionInfo = new VersionInfo() {

        @Override
        public String getAbbreviatedProductName() {
            return ABBREVIATED_PRODUCT;
        }

        @Override
        public String getVersionPrefix() {
            return VERSION_PREFIX;
        }

        @Override
        public String getMajorVersion() {
            return VERSION_MAJOR;
        }

        @Override
        public String getMinorVersion() {
            return VERSION_MINOR;
        }

        @Override
        public String getUpdateVersion() {
            return VERSION_UPDATE;
        }
    };
    Mockito.when(serviceLocatorMock.getService(VersionInfo.class)).thenReturn(versionInfo);
    File basePath = new File(BASE_PATH);
    basePath.mkdirs();
    // Add a file handler with UniformLogFormatter
    uniformFormatHandler = new FileHandler(ULF_LOG);
    uniformFormatHandler.setLevel(Level.FINE);
    uniformFormatHandler.setFormatter(new UniformLogFormatter(excludeFields));
    // Add a file handler with ODLLogFormatter
    odlFormatHandler = new FileHandler(ODL_LOG);
    odlFormatHandler.setLevel(Level.FINE);
    odlFormatHandler.setFormatter(new ODLLogFormatter(excludeFields));
    // Add a file handler with JSONLogFormatter
    jsonFormatHandler = new FileHandler(JSON_LOG);
    jsonFormatHandler.setLevel(Level.FINE);
    jsonFormatHandler.setFormatter(new JSONLogFormatter(excludeFields));
    consoleHandler = new ConsoleHandler();
    consoleHandler.setFormatter(new UniformLogFormatter(excludeFields));
    LOGGER.addHandler(uniformFormatHandler);
    LOGGER.addHandler(odlFormatHandler);
    LOGGER.addHandler(jsonFormatHandler);
    boolean enableConsoleHandler = Boolean.getBoolean(LoggingExclusionTest.class.getName() + ".enableConsoleHandler");
    if (enableConsoleHandler) {
        LOGGER.addHandler(consoleHandler);
    }
    LOGGER.setUseParentHandlers(false);
    LOGGER.setLevel(Level.FINE);
}
Also used : VersionInfo(org.glassfish.api.VersionInfo) JSONLogFormatter(fish.payara.enterprise.server.logging.JSONLogFormatter) File(java.io.File) ConsoleHandler(java.util.logging.ConsoleHandler) FileHandler(java.util.logging.FileHandler)

Aggregations

VersionInfo (org.glassfish.api.VersionInfo)3 JSONLogFormatter (fish.payara.enterprise.server.logging.JSONLogFormatter)1 File (java.io.File)1 ConsoleHandler (java.util.logging.ConsoleHandler)1 FileHandler (java.util.logging.FileHandler)1