module.exports = function (app, express, passport, logger) {

    var nconf = require('nconf'),
//        cachify = require('connect-cachify'),
        winston = require('winston'),
        path = require('path'),
        fs = require('fs'),
        requestLogger = require('winston-request-logger'),
        bodyParser = require('body-parser'),
        methodOverride = require('method-override'),
        multer = require('multer'),
        cookieParser = require('cookie-parser'),
        session = require('express-session'),
        favicon = require('static-favicon'),
        errorHandler = require('errorhandler'),
        ClusterStore = require('strong-cluster-express-store')(session);

    nconf.file({ file: './gebo.json' });
    var logLevel = nconf.get('logLevel');
 
    // load assets node from configuration file.
    var assets = nconf.get('assets') || {};

    // 2014-8-20
    // Logging is configured in gebo.json. Preserved for reference.
    //
    // What kind of environment is this?
//    var env = process.env.NODE_ENV || 'development';
//
//    // Development Configuration
//    if ('development' === env) {
//      // register the request logger
//      app.use(requestLogger.create(logger))
//      app.set('DEBUG', true)
//      app.use(errorHandler({ dumpExceptions: true, showStack: true }))
//    }
//
//    // Production Configuration
//    if ('production' === env) {
//      app.set('DEBUG', false)
//      app.use(errorHandler())
//    }
    
    if (logLevel !== 'off') {
      app.use(requestLogger.create(logger))
      app.set('DEBUG', true)
      app.use(errorHandler({ dumpExceptions: true, showStack: true }))
    }

    /**
     * allowCrossDomain
     */
    var allowCrossDomain = function(req, res, next) {
        res.header('Access-Control-Allow-Origin', '*');
        res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
        res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With');

        if ('OPTIONS' === req.method) {
          res.send(200);
        }
        else {
          next();
        }
    };

    /**
     * Redirect to HTTPS
     *
     * Peter Lyons, 2013-4-5
     * http://stackoverflow.com/questions/15813677/https-redirection-for-all-routes-node-js-express-security-concerns
     */
    function requireHttps(req, res, next) {
        if (!req.secure) {
          var url = nconf.get('domain') + ':' + nconf.get('httpsPort') + req.url;
          console.log(url);
          return res.redirect(url);
        }
        next();
      }


    // Cachify Asset Configuration
//    app.use(cachify.setup(assets, {
//        root: root + '/public',
//        production: nconf.get('cachify')
//    }));

    // Global Configuration
    app.use(allowCrossDomain);

    // Find alternate views
    try {
        var viewsDir = fs.readdirSync('./views');
        app.set('views', './views');
    }
    catch(err) {
        app.set('views', __dirname + '/../views');
    }
    //app.set('views', './views');

    app.set('view engine', 'jade');
    app.set('view options', { layout: false });
    app.use(cookieParser());
    app.use(multer({
                        dest: '/tmp/',
                        limits: {
                            fieldSize: 4000000
                        },
                    }));
    // body-parser is needed for HAI login
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({ extended: true }));
    app.use(methodOverride());

    // Find alternate public directory
    try {
        var publicDir = fs.readdirSync('./public');
        app.use(express.static('./public'));
    }
    catch(err) {
        app.use(express.static(__dirname + '/../public'));
    }

    // Find alternate favicon 
    try {
        var faviconFile = fs.openSync('./favicon.ico');
        faviconFile.close();
        app.use(favicon('./favicon.ico'));
    }
    catch(err) {
        app.use(favicon(__dirname + '/../favicon.ico'));
    }

    app.use(session({
                saveUninitialized: true,
                resave: true,
                store: new ClusterStore(),
                secret: 'What the halo!?'}));
    app.use(requireHttps);
    // Initialize Passport!  Also use passport.session() middleware, to support
    // persistent login sessions (recommended).
    app.use(passport.initialize());
    app.use(passport.session());
};

@@ -46,16 +46,8 @@
 port
-, logger
 ) %7B%0A
@@ -231,67 +231,8 @@
 '),%0A
-        requestLogger = require('winston-request-logger'),%0A
     
@@ -321,24 +321,60 @@
 override'),%0A
+        morgan = require('morgan'),%0A
         mult
@@ -842,25 +842,8 @@
 %7D;%0A%0A
-    // 2014-8-20%0A
     
@@ -883,513 +883,115 @@
 json
-. Preserved for reference.%0A    //%0A    // What kind of environment is this?%0A//    var env = process.env.NODE_ENV %7C%7C 'development';%0A//%0A//    // Development Configuration%0A//    if ('development' === env) %7B%0A//      // register the request logger%0A//      app.use(requestLogger.create(logger))%0A//      app.set('DEBUG', true)%0A//      app.use(errorHandler(%7B dumpExceptions: true, showStack: true %7D))%0A//    %7D%0A//%0A//    // Production Configuration%0A//    if ('production' === env) %7B%0A//      app.set('DEBUG', false)%0A//
+%0A    if (logLevel === 'info') %7B%0A      app.use(morgan('common'));%0A    %7D%0A    else if (logLevel ==='trace') %7B%0A
     
@@ -1004,37 +1004,30 @@
 use(
-errorHandler())%0A//
+morgan('dev'));%0A
     %7D%0A
-    %0A
     
@@ -1056,52 +1056,8 @@
 ) %7B%0A
-      app.use(requestLogger.create(logger))%0A
     
@@ -1080,16 +1080,17 @@
 ', true)
+;
 %0A      a
@@ -1152,16 +1152,17 @@
 true %7D))
+;
 %0A    %7D%0A%0A

Deploy morgan logger with three log levels