实例构造
@param config    配置
@param http      请求参数
@param logger    日志
@constructor
359858
function(config, http, logger){
        this.Config = config;
        this.http = http;
        this.logger = logger;

        // 绑定请求
        var urlPath = http.request.url.pathname;

        logger.info("收到请求:" + urlPath + " | 参数:" + JSON.stringify(http.params));

        if (urlPath.indexOf('.') > -1)
        {
            logger.warn("错误的接口地址:" + urlPath);
            this.out({message:"错误的请求"});
            return;
        }
        var infPath = path.join(config.path.root, config.path.controller, urlPath + ".js");

        // 传入的沙箱对象
        var sandbox = {
            Lay: this
        };

        var that = this;
        fs.exists(infPath, function(exsist){
            if (exsist)
            {
                fs.readFile(infPath, function(err, data){
                    // 进入沙箱执行
                    vm.runInNewContext(data, sandbox, 'myfile.vm');
                });
            }
            else
            {
                logger.warn("未找到接口文件:" + infPath);
                that.out({message:"错误的请求"});
            }
        });
    }
1311955
private void parseErrorLog(Map<String, Object> config) {
        String filename = (String) config.get("error.filePath");
        if (null == filename || 0 == filename.trim().length()) {
            return;
        }
        try {
            this.debugLog = new DebugLogger(filename);
        } catch (Throwable t) {
            FFDCFilter.processException(t, getClass().getName() + ".parseErrorLog", "1", this);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "Logging service was unable to open debug file: " + filename + "; " + t);
            }
            return;
        }

        // check the debug log level setting
        String levelName = (String) config.get("error.logLevel");
        this.debugLog.setCurrentLevel(LogUtils.convertDebugLevel(levelName));

        String size = (String) config.get("error.maximumSize");
        if (null != size) {
            // convert from MB to bytes
            if (!this.debugLog.setMaximumSize(convertInt(size, 0) * 1048576L)) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Logging service has invalid error log size: " + size);
                }
            }
        }

        // check for the max backup files
        String backups = (String) config.get("error.maximumBackupFiles");
        if (null != backups) {
            this.debugLog.setMaximumBackupFiles(convertInt(backups, 1));
        }

    }
939251
function Logger(tag, logger) {
  this._tag = tag;
  this._logger = logger;
  this._level = 1;

  // support the various logging functions
  var _this = this;
  ['log', 'trace', 'debug', 'info', 'warn', 'warning', 'error', 'fatal', 'exception'].forEach(function(f) {
    _this[f] = function() {
      if (_this._logger && LEVEL[f] <= _this._level) {
        var message;
        // add the tag to the message
        for (var i = 0; i < arguments.length; ++i) {
          if (typeof arguments[i] === 'string') {
            arguments[i] = "["+_this._tag+"] " + arguments[i];
            message = arguments[i];
            break;
          }
        }
        var method = _this._logger[f] || _this._logger['log'];
        method.apply(_this._logger, arguments);
      }
    }
  });
}
1316145
function init(config){
    var logger = new LogglyLogger(config);
    logger.validateConfig();

    logger.config = config;
    logger.client = loggly.createClient({
        token: config.token,
        subdomain: config.application,
        auth: config.auth,

        // TOOD: pushing more tags onto this array, or not using them, should be configurable
        tags: [
            config.domain,
            config.machine
        ]

        // Loggly docs say it uses json stringify if json:true
        // JSON stringify does not handle Errors or circulare references well
        // Logger.createEntry handles them well
    });
    return logger;
}
631485
function CommonTransport( logger , config = {} ) {
	this.logger = null ;
	this.monitoring = false ;
	this.minLevel = 0 ;
	this.maxLevel = 7 ;
	this.messageFormatter = logger.messageFormatter.text ;
	this.timeFormatter = logger.timeFormatter.dateTime ;

	Object.defineProperty( this , 'logger' , { value: logger } ) ;

	if ( config.monitoring !== undefined ) { this.monitoring = !! config.monitoring ; }

	if ( config.minLevel !== undefined ) {
		if ( typeof config.minLevel === 'number' ) { this.minLevel = config.minLevel ; }
		else if ( typeof config.minLevel === 'string' ) { this.minLevel = this.logger.levelHash[ config.minLevel ] ; }
	}

	if ( config.maxLevel !== undefined ) {
		if ( typeof config.maxLevel === 'number' ) { this.maxLevel = config.maxLevel ; }
		else if ( typeof config.maxLevel === 'string' ) { this.maxLevel = this.logger.levelHash[ config.maxLevel ] ; }
	}

	if ( config.messageFormatter ) {
		if ( typeof config.messageFormatter === 'function' ) { this.messageFormatter = config.messageFormatter ; }
		else { this.messageFormatter = this.logger.messageFormatter[ config.messageFormatter ] ; }
	}

	if ( config.timeFormatter ) {
		if ( typeof config.timeFormatter === 'function' ) { this.timeFormatter = config.timeFormatter ; }
		else { this.timeFormatter = this.logger.timeFormatter[ config.timeFormatter ] ; }
	}
}
229015
function (config) {
    config = config || {};
    Appender.call(this, config);

    /**
     * Log file name, initialized from the configuration. Folders up to the
     * file must exist beforehand.
     */
    this.fileName = config.fileName;

    /**
     * Append log events to the end of the file when true, clear the file
     * before writing the first log event otherwise.
     */
    this.appendToFile = (typeof config.append !== 'undefined') ?
      !!config.append :
      true;

    /**
     * True to log strings instead of objects
     */
    this.appendStrings = (typeof config.appendStrings !== 'undefined') ?
      config.appendStrings :
      true;

    /**
     * The file stream, initialized by the "start" function
     */
    this.stream = null;
  }
452948
public void setupServerConfigIfNeeds(BootLogger logger, Tomcat server, Connector connector, Properties props,
            List<String> readConfigList) {
        if (props == null) {
            return;
        }
        logger.info("...Reflecting configuration to server: config=" + readConfigList);
        doSetupServerConfig(logger, props, "URIEncoding", value -> connector.setURIEncoding(value));
        doSetupServerConfig(logger, props, "useBodyEncodingForURI", value -> {
            connector.setUseBodyEncodingForURI(isStringBooleanTrue(value));
        });
        doSetupServerConfig(logger, props, "secure", value -> connector.setSecure(isStringBooleanTrue(value)));
        doSetupServerConfig(logger, props, "scheme", value -> connector.setScheme(value));
        doSetupServerConfig(logger, props, "bindAddress", value -> connector.setProperty("address", value));
        doSetupServerConfig(logger, props, "proxyPort", value -> connector.setProxyPort(toInt("proxyPort(config)", value)));
        doSetupServerConfig(logger, props, "maxHttpHeaderSize", value -> {
            reflectPropertyMaxHttpHeaderSize(logger, server, connector, value);
        });
    }
1046751
public void load(FileConfiguration config) {
        this.config = config;
        
        try {
            parse();
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }
1005650
function ConfigLoader(strategies, logger) {
  this.strategies = [];

  if (logger) {
    if (typeof logger.debug !== 'function') {
      throw new Error('Provided logger is required to have method debug().');
    }
    this.logger = logger;
  }

  if (strategies && !(strategies instanceof Array)) {
    throw new Error('Argument \'strategies\' must be an array.');
  }

  for (var i = 0; i < strategies.length; i++) {
    this.add(strategies[i]);
  }
}
1329962
public void configLogger()
    {
        Map<String, Level> logLevels = new HashMap<String, Level>();
        logLevels.put("trace", Level.TRACE);
        logLevels.put("debug", Level.DEBUG);
        logLevels.put("info", Level.INFO);
        logLevels.put("warning", Level.WARNING);
        logLevels.put("error", Level.ERROR);

        if( this.get("logging_log_type", "file").equals("file") ){

            DateFormat dateFormat = new SimpleDateFormat(this.get("logging_current_date_format","yyyy-MM-dd"));
            Date date = new Date();
            String logFileName = (this.get("logging_file_format", "current_date").equals("current_date")) ? dateFormat.format(date) + ".log" : this.get("logging_file_format", "current_date") + ".log";
            Configurator.defaultConfig()
                .writer(new FileWriter(this.get("logging_file_path", "src/main/java/resources/") + logFileName, (this.get("logging_buffered", "false").equals("true")) ? true : false, (this.get("logging_append", "true").equals("true")) ? true : false))
                .level((logLevels.containsKey(this.get("logging_level","debug"))) ? logLevels.get(this.get("logging_level","debug")) : Level.INFO)
                .activate();

        }else if( this.get("logging_log_type", "file").equals("both") ){

            DateFormat dateFormat = new SimpleDateFormat(this.get("logging_current_date_format","yyyy-MM-dd"));
            Date date = new Date();
            String logFileName = (this.get("logging_file_format", "current_date").equals("current_date")) ? dateFormat.format(date) + ".log" : this.get("logging_file_format", "current_date") + ".log";
            Configurator.defaultConfig()
                .writer(new ConsoleWriter())
                .addWriter(new FileWriter(this.get("logging_file_path", "src/main/java/resources/") + logFileName))
                .level((logLevels.containsKey(this.get("logging_level","debug"))) ? logLevels.get(this.get("logging_level","debug")) : Level.INFO)
                .activate();

        }else{

            Configurator.defaultConfig()
                .writer(new ConsoleWriter())
                .level((logLevels.containsKey(this.get("logging_level","debug"))) ? logLevels.get(this.get("logging_level","debug")) : Level.INFO)
                .activate();

        }
    }
144996
function (__config) {

            // Check that supplied configuration is valid
            if (typeof __config == "object" || __config == undefined) {

                config = extend(config, _config);

                // Allow overriding logger
                log = new Log({
                    destination: config.logger || console,
                    logLevel: config.logLevel
                });

            // Fail ...
            } else {
                
                // We need to create a fallback logger
                log = new Log({
                    destination: console,
                    level: 3
                });

                log.throw("core", TypeError("Supplied configuration not valid, must be object or undefined. Supplied type: " + typeof _config));
            }

            // Allow chaining
            return root;

        }
1010135
@Override
    public synchronized void init(LogProviderConfig config) {
        ffdcSummaryPolicy = ((LogProviderConfigImpl) config).getFfdcSummaryPolicy();
        update(config);
    }
1289813
public void setLogger(Logger logger) {

		System.out.println("LOGGER set");
//		if(logger instanceof SimpleFileLogger) {
			this.logger = logger;
			System.out.println("appender added");
			this.logger.addAppender(this);
//		}
	}
1169741
public void init(ServletConfig config)
        throws ServletException
    {
        super.init(config);

        try {
            if (_service == null) {
                String className = getInitParameter("service-class");
                Class<?> serviceClass = null;

                if (className != null) {
                    ClassLoader loader = Thread.currentThread().getContextClassLoader();

                    if (loader != null)
                        serviceClass = Class.forName(className, false, loader);
                    else
                        serviceClass = Class.forName(className);
                }
                else {
                    if (getClass().equals(BurlapServlet.class))
                        throw new ServletException("server must extend BurlapServlet");

                    serviceClass = getClass();
                }

                _service = serviceClass.newInstance();

                if (_service instanceof BurlapServlet)
                    ((BurlapServlet) _service).setService(this);
                if (_service instanceof Service)
                    ((Service) _service).init(getServletConfig());
                else if (_service instanceof Servlet)
                    ((Servlet) _service).init(getServletConfig());
            }

            if (_apiClass == null) {
                String className = getInitParameter("api-class");

                if (className != null) {
                    ClassLoader loader = Thread.currentThread().getContextClassLoader();

                    if (loader != null)
                        _apiClass = Class.forName(className, false, loader);
                    else
                        _apiClass = Class.forName(className);
                }
                else
                    _apiClass = _service.getClass();
            }

            _skeleton = new BurlapSkeleton(_service, _apiClass);
        } catch (ServletException e) {
            throw e;
        } catch (Exception e) {
            throw new ServletException(e);
        }
    }
50137
@Override
    public void init(ServletConfig config) throws ServletException {
        LOGGER.info("Starting " + Config.getInstance().getApplicationName());
        super.init(config);

        final Info info = new Info()
                .title(Config.getInstance().getApplicationName() + " API")
                .version(Config.getInstance().getApplicationVersion());

        final Swagger swagger = new Swagger()
                .info(info)
                .securityDefinition("X-Api-Key", new ApiKeyAuthDefinition("X-Api-Key", In.HEADER));

        // Dynamically get the url-pattern from web.xml and use that as the 'baseUrl' for
        // the API documentation
        final ServletContext servletContext = getServletContext();
        final ServletRegistration servletRegistration = servletContext.getServletRegistration(config.getServletName());
        final Collection<String> mappings = servletRegistration.getMappings();
        if (! Collections.isEmpty(mappings)) {
            String baseUrl = mappings.iterator().next();
            if (baseUrl.charAt(0) != '/') {
                baseUrl = "/" + baseUrl;
            }
            baseUrl = baseUrl.replace("/*", "").replaceAll("\\/$", "");
            swagger.basePath(config.getServletContext().getContextPath() + baseUrl);
        }

        new SwaggerContextService().withServletConfig(config).updateSwagger(swagger).initScanner();

        // Initializes the KeyManager
        KeyManager.getInstance();

        // Log all Java System Properties
        SecurityUtil.logJavaSystemProperties();

        // Determine if Watchdog logging is enabled and if so, start interval logging
        final int interval = Config.getInstance().getPropertyAsInt(Config.AlpineKey.WATCHDOG_LOGGING_INTERVAL);
        if (interval > 0) {
            final IntervalLoggerController wd = SecurityLoggingFactory.getControllerInstance();
            wd.start(interval * 1000); // Interval is defined in seconds
        }
        LOGGER.info(Config.getInstance().getApplicationName() + " is ready");
    }
181795
private static HttpURLConnection setup(HttpsFileUploaderConfig config) throws MalformedURLException, IOException {
        HttpURLConnection httpUrlConnection;
        boolean isHttps = false;
        URL url = config.getURL();
        if (url.getProtocol().equalsIgnoreCase("https")) {
            isHttps = true;
        }

        if (config.usesProxy()) {
            Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(config.getProxyAddress(), config.getProxyPort()));
            httpUrlConnection = (HttpURLConnection) url.openConnection(proxy);
        } else {
            httpUrlConnection = (HttpURLConnection) url.openConnection();
        }
        
        
        if (!config.isValidateCertificates() && isHttps) {
            SSLUtils.setNoValidate(((HttpsURLConnection) httpUrlConnection), config.getAcceptedIssuers());
        }
        
        
        httpUrlConnection.setUseCaches(false);  // do not use connection caches
        httpUrlConnection.setDoOutput(true);

        // Set timeouts
        httpUrlConnection.setConnectTimeout(config.getConnectTimeoutMs());
        httpUrlConnection.setReadTimeout(config.getReadTimeoutMs());

        httpUrlConnection.setRequestMethod("POST");
        httpUrlConnection.setRequestProperty("Connection", "Keep-Alive");
        httpUrlConnection.setRequestProperty("Cache-Control", "no-cache");
        httpUrlConnection.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + MULTIPART_BOUNDARY);
        
        // Sets additional headers
        if (config.getAdditionalHeaders() != null) {
            for(Entry<String,String> e : config.getAdditionalHeaders().entrySet()) {
                // We use the 'set' method here and not the 'add' method because
                // it should be allowed for example for the user to override Java's default
                // User-Agent value. 
                httpUrlConnection.setRequestProperty(e.getKey(), e.getValue());
            }
        }
        
        
        if (config.endpointRequiresAuthentication()) {
            String authString = config.getEndpointUsername() + ":" + config.getEndpointPassword();

            // The only public Base64 encoder that exist in Java 7 and before is from the
            // JAXB package so we will (mis)use that here for Base64 encoding.        
            // Note: Java 8 will finally have a Base64 class in the Util package.
            String authStringEnc = javax.xml.bind.DatatypeConverter.printBase64Binary(authString.getBytes());
            httpUrlConnection.setRequestProperty("Authorization", "Basic " + authStringEnc);
        }
        
        return httpUrlConnection;
    }
350939
func Logger(logger chronograf.Logger, next http.Handler) http.Handler {
	fn := func(w http.ResponseWriter, r *http.Request) {
		now := time.Now()
		logger.WithField("component", "server").
			WithField("remote_addr", r.RemoteAddr).
			WithField("method", r.Method).
			WithField("url", r.URL).
			Debug("Request")

		sw := &statusWriter{
			ResponseWriter: w,
		}
		if f, ok := w.(http.Flusher); ok {
			sw.Flusher = f
		}
		next.ServeHTTP(sw, r)
		later := time.Now()
		elapsed := later.Sub(now)

		logger.
			WithField("component", "server").
			WithField("remote_addr", r.RemoteAddr).
			WithField("method", r.Method).
			WithField("response_time", elapsed.String()).
			WithField("status", sw.Status()).
			Info("Response: ", http.StatusText(sw.Status()))
	}
	return http.HandlerFunc(fn)
}