Search in sources :

Example 11 with Category

use of org.apache.log4j.Category in project zm-mailbox by Zimbra.

the class ZimbraPatternLayout method main.

public static void main(String[] args) {
    Layout layout = new ZimbraPatternLayout("[%z] - %m%n");
    Category cat = Category.getInstance("some.cat");
    cat.addAppender(new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT));
    ZimbraLog.addAccountNameToContext("my@account.com");
    ZimbraLog.addMboxToContext(99);
    cat.debug("Hello, log");
    cat.info("Hello again...");
    ZimbraLog.clearContext();
    cat.info("No more context");
}
Also used : ConsoleAppender(org.apache.log4j.ConsoleAppender) Category(org.apache.log4j.Category) Layout(org.apache.log4j.Layout) PatternLayout(org.apache.log4j.PatternLayout)

Example 12 with Category

use of org.apache.log4j.Category in project alluxio by Alluxio.

the class LogUtils method process.

private static void process(org.apache.log4j.Logger log, String level, LogInfo result) throws IOException {
    if (log == null) {
        result.setMessage("log is null.");
        return;
    }
    if (level != null) {
        if (!level.equals(org.apache.log4j.Level.toLevel(level).toString())) {
            result.setMessage("Bad level : " + level);
        } else {
            log.setLevel(org.apache.log4j.Level.toLevel(level));
            result.setMessage("Setting Level to " + level);
        }
    }
    org.apache.log4j.Level lev = null;
    Category category = log;
    while ((category != null) && ((lev = category.getLevel()) == null)) {
        category = category.getParent();
    }
    if (lev != null) {
        result.setLevel(lev.toString());
    }
}
Also used : Category(org.apache.log4j.Category)

Aggregations

Category (org.apache.log4j.Category)12 LoggingEvent (org.apache.log4j.spi.LoggingEvent)4 Enumeration (java.util.Enumeration)3 ConsoleAppender (org.apache.log4j.ConsoleAppender)3 Level (org.apache.log4j.Level)3 Logger (org.apache.log4j.Logger)3 Test (org.junit.Test)3 Date (java.util.Date)2 Appender (org.apache.log4j.Appender)2 FileAppender (org.apache.log4j.FileAppender)2 Layout (org.apache.log4j.Layout)2 PatternLayout (org.apache.log4j.PatternLayout)2 LocationInfo (org.apache.log4j.spi.LocationInfo)2 CapabilitiesLoder (com.qaprosoft.carina.core.foundation.webdriver.core.capability.CapabilitiesLoder)1 JULBridgeHandler (com.twitter.common.logging.julbridge.JULBridgeHandler)1 LogEvent (io.fabric8.insight.log.LogEvent)1 FileNotFoundException (java.io.FileNotFoundException)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 Calendar (java.util.Calendar)1