Skip to content

Unable to get logs in JSON format with native binary #159

@devatherock

Description

@devatherock

Couldn't find a way to pass logback.configurationFile system property to the native binary. Could be fixed by introducing an environment variable LOGBACK_CONFIGURATION_FILE, in of the below two ways.

Option 1:

if (System.getProperty(PROP_LOGBACK_CONFIG) == null &&
                System.getenv(ENV_LOGBACK_CONFIG) != null) {
            LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

            try {
                JoranConfigurator configurator = new JoranConfigurator();
                configurator.setContext(context);
                context.reset();
                configurator.doConfigure(
                        Application.class.getClassLoader().getResourceAsStream(System.getenv(ENV_LOGBACK_CONFIG)));
            } catch (JoranException je) {
                // StatusPrinter will handle this
            }
            StatusPrinter.printInCaseOfErrorsOrWarnings(context);
}

Option 2:

if (System.getProperty(PROP_LOGBACK_CONFIG) == null &&
                System.getenv(ENV_LOGBACK_CONFIG) != null) {
            System.setProperty(PROP_LOGBACK_CONFIG, System.getenv(ENV_LOGBACK_CONFIG));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions