Examples of LoggerContext


Examples of ch.qos.logback.classic.LoggerContext

        // Init GSON for underscores
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES);
        this.gson = gsonBuilder.create();
        this.patternLayout = new PatternLayout();
        this.patternLayout.setContext(new LoggerContext());
        this.patternLayout.setPattern(messagePattern);
        this.patternLayout.start();
       
        if ( shortMessagePattern == null ) {
            this.shortPatternLayout = null;
        } else {
            this.shortPatternLayout = new PatternLayout();
            this.shortPatternLayout.setContext(new LoggerContext());
            this.shortPatternLayout.setPattern(shortMessagePattern);
            this.shortPatternLayout.start();
        }
    }
View Full Code Here

Examples of ch.qos.logback.classic.LoggerContext

        server.shutdown();
        logger.debug("This is a test with a really long ending: " + longMessage);
    }

    private void addTypedFieldToAppender() throws JoranException {
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        JoranConfigurator joranConfigurator = new JoranConfigurator();
        joranConfigurator.setContext(lc);
        joranConfigurator.doConfigure(Resources.getResource("typedFields.xml"));
    }
View Full Code Here

Examples of ch.qos.logback.classic.LoggerContext

        joranConfigurator.setContext(lc);
        joranConfigurator.doConfigure(Resources.getResource("typedFields.xml"));
    }

    private void addStaticFieldToAppender() throws JoranException {
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        JoranConfigurator joranConfigurator = new JoranConfigurator();
        joranConfigurator.setContext(lc);
        joranConfigurator.doConfigure(Resources.getResource("staticAdditionalFields.xml"));
    }
View Full Code Here

Examples of ch.qos.logback.classic.LoggerContext

    @RequestMapping(value = "/rest/logs",
            method = RequestMethod.PUT)
    @ResponseStatus(HttpStatus.NO_CONTENT)
    @Timed
    public void changeLevel(@RequestBody LoggerDTO jsonLogger) {
        LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
        context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel()));
    }
View Full Code Here

Examples of ch.qos.logback.classic.LoggerContext

import com.google.common.collect.Lists;

public class LogbackHook<E> extends AppenderBase<E> {

  public static void attachToRootLogger() {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

    LogbackHook appender = new LogbackHook();
    // PatternLayoutEncoder encoder = new PatternLayoutEncoder();
    // encoder.setContext(loggerContext);
    // encoder.setPattern("%-4relative [%thread] %-5level %logger{35} - %msg%n");
    // encoder.start();

    // appender.setLayout(new PatternLayout("%d [%t] %-5p %c %x - %m%n"));
    appender.start();

    Logger logbackLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    logbackLogger.addAppender(appender);
  }
View Full Code Here

Examples of ch.qos.logback.classic.LoggerContext

        if (!logbackConfiguration.exists())
            return;

        logger.info("Loading logback configuration from \"{}\".", logbackConfiguration);
       
        LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
        context.reset();

        try {

            // Initialize logback
            JoranConfigurator configurator = new JoranConfigurator();
View Full Code Here

Examples of ch.qos.logback.classic.LoggerContext

    } else {
      usage("Wrong number of arguments.");
    }

    String configFile = argv[1];
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    configureLC(lc, configFile);

    SimpleSocketServer sss = createServer(serverClass, lc, port);
    sss.start();
  }
View Full Code Here

Examples of org.apache.logging.log4j.core.LoggerContext

     * @param currentContext If true returns the current Context, if false returns the Context appropriate
     * for the caller if a more appropriate Context can be determined.
     * @return The LoggerContext.
     */
    public LoggerContext getContext(String fqcn, boolean currentContext) {
        LoggerContext ctx = selector.getContext(fqcn, currentContext);
        synchronized (ctx) {
            if (recursive.get() != null || ctx.isStarted()) {
                return ctx;
            }
            try {
                recursive.set(this);
                ctx.start();
                return ctx;
            } finally {
                recursive.remove();
            }
        }
View Full Code Here

Examples of org.apache.logging.log4j.core.LoggerContext

    private static final String CONFIG = "log4j-test1.xml";

    @BeforeClass
    public static void setUpClass() {
        System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
        context.getConfiguration();
    }
View Full Code Here

Examples of org.apache.logging.log4j.core.LoggerContext

    }

    @AfterClass
    public static void cleanUpClass() {
        System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
        final LoggerContext context = (LoggerContext) LogManager.getContext(false);
        context.reconfigure();
        StatusLogger.getLogger().reset();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.