Java Code Examples for org.apache.juli.logging.LogFactory#getLog()

The following examples show how to use org.apache.juli.logging.LogFactory#getLog() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggingBaseTest.java    From tomcat-mongo-access-log with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    // Create catalina.base directory
    tempDir = new File(System.getProperty("tomcat.test.temp", "src/test/java/output"));
    if (!tempDir.mkdirs() && !tempDir.isDirectory()) {
        fail("Unable to create temporary directory for test");
    }

    System.setProperty("catalina.base", tempDir.getAbsolutePath());

    // Configure logging
    System.setProperty("java.util.logging.manager",
            "org.apache.juli.ClassLoaderLogManager");
    System.setProperty("java.util.logging.config.file", new File(
            getBuildDirectory(), "conf/logging.properties").toString());

    // Get log instance after logging has been configured
    log = LogFactory.getLog(getClass());
}
 
Example 2
Source File: LoggingBaseTest.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    // Create catalina.base directory
    tempDir = new File(System.getProperty("tomcat.test.temp", "output/tmp"));
    if (!tempDir.mkdirs() && !tempDir.isDirectory()) {
        fail("Unable to create temporary directory for test");
    }

    System.setProperty("catalina.base", tempDir.getAbsolutePath());

    // Configure logging
    System.setProperty("java.util.logging.manager",
            "org.apache.juli.ClassLoaderLogManager");
    System.setProperty("java.util.logging.config.file", new File(
            getBuildDirectory(), "conf/logging.properties").toString());

    // Get log instance after logging has been configured
    log = LogFactory.getLog(getClass());
    log.info("Starting test case [" + testName.getMethodName() + "]");
}
 
Example 3
Source File: Digester.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * <p>
 * Provide a hook for lazy configuration of this <code>Digester</code>
 * instance.  The default implementation does nothing, but subclasses
 * can override as needed.
 * </p>
 *
 * <p>
 * <strong>Note</strong> This method may be called more than once.
 * Once only initialization code should be placed in {@link #initialize}
 * or the code should take responsibility by checking and setting the 
 * {@link #configured} flag.
 * </p>
 */
protected void configure() {

    // Do not configure more than once
    if (configured) {
        return;
    }

    log = LogFactory.getLog("org.apache.tomcat.util.digester.Digester");
    saxLog = LogFactory.getLog("org.apache.tomcat.util.digester.Digester.sax");

    // Perform lazy configuration as needed
    initialize(); // call hook method for subclasses that want to be initialized once only
    // Nothing else required by default

    // Set the configuration flag to avoid repeating
    configured = true;

}
 
Example 4
Source File: LoggingBaseTest.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    // Create catalina.base directory
    tempDir = new File(System.getProperty("tomcat.test.temp", "output/tmp"));
    if (!tempDir.mkdirs() && !tempDir.isDirectory()) {
        fail("Unable to create temporary directory for test");
    }

    System.setProperty("catalina.base", tempDir.getAbsolutePath());

    // Configure logging
    System.setProperty("java.util.logging.manager",
            "org.apache.juli.ClassLoaderLogManager");
    System.setProperty("java.util.logging.config.file", new File(
            getBuildDirectory(), "conf/logging.properties").toString());

    // Get log instance after logging has been configured
    log = LogFactory.getLog(getClass());
    log.info("Starting test case [" + testName.getMethodName() + "]");
}
 
Example 5
Source File: Digester.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
public static void replaceSystemProperties() {
    Log log = LogFactory.getLog(Digester.class);
    if (propertySource != null) {
        IntrospectionUtils.PropertySource[] propertySources =
                new IntrospectionUtils.PropertySource[] { propertySource };
        Properties properties = System.getProperties();
        Set<String> names = properties.stringPropertyNames();
        for (String name : names) {
            String value = System.getProperty(name);
            if (value != null) {
                try {
                    String newValue = IntrospectionUtils.replaceProperties(value, null, propertySources, null);
                    if (!value.equals(newValue)) {
                        System.setProperty(name, newValue);
                    }
                } catch (Exception e) {
                    log.warn(sm.getString("digester.failedToUpdateSystemProperty", name, value), e);
                }
            }
        }
    }
}
 
Example 6
Source File: Digester.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * <p>
 * Provide a hook for lazy configuration of this <code>Digester</code>
 * instance.  The default implementation does nothing, but subclasses
 * can override as needed.
 * </p>
 *
 * <p>
 * <strong>Note</strong> This method may be called more than once.
 * Once only initialization code should be placed in {@link #initialize}
 * or the code should take responsibility by checking and setting the 
 * {@link #configured} flag.
 * </p>
 */
protected void configure() {

    // Do not configure more than once
    if (configured) {
        return;
    }

    log = LogFactory.getLog("org.apache.tomcat.util.digester.Digester");
    saxLog = LogFactory.getLog("org.apache.tomcat.util.digester.Digester.sax");

    // Perform lazy configuration as needed
    initialize(); // call hook method for subclasses that want to be initialized once only
    // Nothing else required by default

    // Set the configuration flag to avoid repeating
    configured = true;

}
 
Example 7
Source File: SecurityClassLoad.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public static void securityClassLoad(ClassLoader loader) {

        if (System.getSecurityManager() == null) {
            return;
        }

        final String basePackage = "org.apache.jasper.";
        try {
            // Ensure XMLInputFactory is loaded with Tomcat's class loader
            loader.loadClass(basePackage + "compiler.EncodingDetector");

            loader.loadClass(basePackage + "runtime.JspFactoryImpl$PrivilegedGetPageContext");
            loader.loadClass(basePackage + "runtime.JspFactoryImpl$PrivilegedReleasePageContext");

            loader.loadClass(basePackage + "runtime.JspRuntimeLibrary");

            loader.loadClass(basePackage + "runtime.ServletResponseWrapperInclude");
            loader.loadClass(basePackage + "runtime.TagHandlerPool");
            loader.loadClass(basePackage + "runtime.JspFragmentHelper");

            loader.loadClass(basePackage + "runtime.ProtectedFunctionMapper");

            loader.loadClass(basePackage + "runtime.PageContextImpl");
            loadAnonymousInnerClasses(loader, basePackage + "runtime.PageContextImpl");

            loader.loadClass(basePackage + "runtime.JspContextWrapper");

            // Trigger loading of class and reading of property
            SecurityUtil.isPackageProtectionEnabled();

            loader.loadClass(basePackage + "servlet.JspServletWrapper");

            loadAnonymousInnerClasses(loader, "runtime.JspWriterImpl");
        } catch (ClassNotFoundException ex) {
            Log log = LogFactory.getLog(SecurityClassLoad.class);
            log.error("SecurityClassLoad", ex);
        }
    }
 
Example 8
Source File: ContainerBase.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Return the Logger for this Container.
 */
@Override
public Log getLogger() {

    if (logger != null)
        return (logger);
    logger = LogFactory.getLog(logName());
    return (logger);

}
 
Example 9
Source File: ContainerBase.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Return the Logger for this Container.
 */
@Override
public Log getLogger() {

    if (logger != null)
        return (logger);
    logger = LogFactory.getLog(logName());
    return (logger);

}
 
Example 10
Source File: CallbackHandlerImpl.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

    String name = null;
    Principal principal = null;
    Subject subject = null;
    String[] groups = null;

    if (callbacks != null) {
        // Need to combine data from multiple callbacks so use this to hold
        // the data
        // Process the callbacks
        for (Callback callback : callbacks) {
            if (callback instanceof CallerPrincipalCallback) {
                CallerPrincipalCallback cpc = (CallerPrincipalCallback) callback;
                name = cpc.getName();
                principal = cpc.getPrincipal();
                subject = cpc.getSubject();
            } else if (callback instanceof GroupPrincipalCallback) {
                GroupPrincipalCallback gpc = (GroupPrincipalCallback) callback;
                groups = gpc.getGroups();
            } else {
                // This is a singleton so need to get correct Logger for
                // current TCCL
                Log log = LogFactory.getLog(CallbackHandlerImpl.class);
                log.error(sm.getString("callbackHandlerImpl.jaspicCallbackMissing",
                        callback.getClass().getName()));
            }
        }

        // Create the GenericPrincipal
        Principal gp = getPrincipal(principal, name, groups);
        if (subject != null && gp != null) {
            subject.getPrivateCredentials().add(gp);
        }
    }
}
 
Example 11
Source File: DigesterFactory.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
private static String locationFor(String name) {
    URL location = CLASS_SERVLET_CONTEXT.getResource("resources/" + name);
    if (location == null && CLASS_JSP_CONTEXT != null) {
        location = CLASS_JSP_CONTEXT.getResource("resources/" + name);
    }
    if (location == null) {
        Log log = LogFactory.getLog(DigesterFactory.class);
        log.warn(sm.getString("digesterFactory.missingSchema", name));
        return null;
    }
    return location.toExternalForm();
}
 
Example 12
Source File: Digester.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * <p>
 * Provide a hook for lazy configuration of this <code>Digester</code>
 * instance.  The default implementation does nothing, but subclasses
 * can override as needed.
 * </p>
 *
 * <p>
 * <strong>Note</strong> This method may be called more than once.
 * </p>
 */
protected void configure() {

    // Do not configure more than once
    if (configured) {
        return;
    }

    log = LogFactory.getLog("org.apache.tomcat.util.digester.Digester");
    saxLog = LogFactory.getLog("org.apache.tomcat.util.digester.Digester.sax");

    // Set the configuration flag to avoid repeating
    configured = true;
}
 
Example 13
Source File: ContainerBase.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Return the Logger for this Container.
 */
@Override
public Log getLogger() {
    if (logger != null)
        return logger;
    logger = LogFactory.getLog(getLogName());
    return logger;
}
 
Example 14
Source File: ReplicatedMap.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
private Log getLog() {
    if (log == null) {
        synchronized (this) {
            if (log == null) {
                log = LogFactory.getLog(ReplicatedMap.class);
            }
        }
    }
    return log;
}
 
Example 15
Source File: LazyReplicatedMap.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
private Log getLog() {
    if (log == null) {
        synchronized (this) {
            if (log == null) {
                log = LogFactory.getLog(LazyReplicatedMap.class);
            }
        }
    }
    return log;
}
 
Example 16
Source File: RewriteValve.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public void setConfiguration(String configuration)
    throws Exception {
    if (containerLog == null) {
        containerLog = LogFactory.getLog(getContainer().getLogName() + ".rewrite");
    }
    maps.clear();
    parse(new BufferedReader(new StringReader(configuration)));
}
 
Example 17
Source File: LoggingBaseTest.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    log = LogFactory.getLog(getClass());
    log.info("Starting test case [" + testName.getMethodName() + "]");
}
 
Example 18
Source File: TomcatLog.java    From uavstack with Apache License 2.0 4 votes vote down vote up
public TomcatLog(String name) {
    super(name);
    this.log = LogFactory.getLog(name);
    Boolean debugcheck = Boolean.valueOf(CatalinaProperties.getProperty("com.creditease.monitor.debug"));
    this.setDebugable(debugcheck);
}
 
Example 19
Source File: RewriteValve.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
protected void initInternal() throws LifecycleException {
    super.initInternal();
    containerLog = LogFactory.getLog(getContainer().getLogName() + ".rewrite");
}