view artifact-database/src/main/java/de/intevation/artifactdatabase/App.java @ 83:8c4638abd518

Installed a SLF4J bridge to route incoming jul logs (used by restlet) to log4j. artifacts/trunk@820 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 22 Mar 2010 15:54:06 +0000
parents f69e5b87f05f
children 0f48188a6e02
line wrap: on
line source
package de.intevation.artifactdatabase;

import de.intevation.artifactdatabase.rest.Standalone;

import java.io.File;

import java.net.MalformedURLException;

import org.apache.log4j.PropertyConfigurator;

import org.slf4j.bridge.SLF4JBridgeHandler;


/**
 * Starting point of the artifact database.
 *
 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
 */
public class App
{
    public static final String LOG4J_PROPERTIES =
        "log4j.properties";

    public static final void configureLogging() {
        File configDir = Config.getConfigDirectory();
        File propFile = new File(configDir, LOG4J_PROPERTIES);

        if (propFile.isFile() && propFile.canRead()) {
            try {
                PropertyConfigurator.configure(propFile.toURI().toURL());
                SLF4JBridgeHandler.install();
            }
            catch (MalformedURLException mue) {
                mue.printStackTrace(System.err);
            }
        }
    }

    public static void main(String[] args) {

        configureLogging();

        FactoryBootstrap bootstrap = new FactoryBootstrap();

        bootstrap.boot();

        Backend backend = new Backend();

        ArtifactDatabaseImpl db = new ArtifactDatabaseImpl(
            bootstrap, backend);

        DatabaseCleaner cleaner = new DatabaseCleaner(
            bootstrap.getContext(), backend);

        bootstrap = null;

        backend.setCleaner(cleaner);

        cleaner.setFilter(db);

        cleaner.start();

        Standalone.startAsServer(db);
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org