• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Log4jConfigListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.web.util.Log4jConfigListener的典型用法代码示例。如果您正苦于以下问题:Java Log4jConfigListener类的具体用法?Java Log4jConfigListener怎么用?Java Log4jConfigListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Log4jConfigListener类属于org.springframework.web.util包,在下文中一共展示了Log4jConfigListener类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: start

import org.springframework.web.util.Log4jConfigListener; //导入依赖的package包/类
public static Server start(JettyProperties properties) throws Throwable {

        QueuedThreadPool threadPool = new QueuedThreadPool();
        threadPool.setMaxThreads(properties.jettyThreadPoolCount);

        Server server = new Server(threadPool);

        ServerConnector http = new ServerConnector(server,new HttpConnectionFactory());
        http.setPort(properties.jettyPort);
        server.addConnector(http);

        WebAppContext context = new WebAppContext();

        // Logging configured per environment:
        context.addEventListener(new Log4jConfigListener());
        context.setInitParameter("log4jConfigLocation", "file:" + properties.log4jConfigPath);
        context.setInitParameter("log4jExposeWebAppRoot", "false");

        context.setDescriptor(new ClassPathResource("src/main/webapp/WEB-INF/web.xml").getURI().toString());

        if (properties.customWebappContextPath.isPresent()) {
            context.setResourceBase(properties.customWebappContextPath.get());
        } else {
            context.setResourceBase(new ClassPathResource("src/main/webapp").getURI().toString());
        }


        context.setContextPath("/");
        context.setParentLoaderPriority(true);
        context.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");

        context.setInitParameter("spring.profiles.active", properties.springProfile);

        server.setHandler(context);
        server.start();
        return server;
    }
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:38,代码来源:JettyServer.java


示例2: initLog4j

import org.springframework.web.util.Log4jConfigListener; //导入依赖的package包/类
protected void initLog4j(ServletContext servletContext) {
    final String log4jConfigLocationParam = "log4jConfigLocation";
    final String log4jConfigLocation = servletContext.getInitParameter(log4jConfigLocationParam);
    if(Strings.isNullOrEmpty(log4jConfigLocation)) {
        servletContext.setInitParameter(log4jConfigLocationParam, getDefaultLog4jConfigLocation());
    }
    servletContext.setInitParameter("log4jExposeWebAppRoot", "false");

    servletContext.addListener(Log4jConfigListener.class);
}
 
开发者ID:indeedeng,项目名称:iupload,代码行数:11,代码来源:WebAppInitializer.java


示例3: addListeners

import org.springframework.web.util.Log4jConfigListener; //导入依赖的package包/类
protected void addListeners(final ServletContext ctx) {
    ctx.addListener(new ContextLoaderListener(rootContext));
    Log4jConfigListener lcl = new Log4jConfigListener();
    ctx.addListener(lcl);
}
 
开发者ID:rockagen,项目名称:security-stateless-samples,代码行数:6,代码来源:BootStrap.java


示例4: onStartup

import org.springframework.web.util.Log4jConfigListener; //导入依赖的package包/类
@Override
    public void onStartup(ServletContext servletContext) throws ServletException {
            
            // Setup Context to Accept Annotated Classes on Input (including plain Spring {@code @Component}
            // Stereotypes in addition to JSR-330 Compliant Classes using {@code javax.inject}
            AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
            
            //context.setConfigLocation(APP_CONFIG_LOCATION);
            context.setConfigLocation(APP_CONFIG_LOCATION);
            
            /* 
            * Add a Spring Security Filter using the JEE6 Filter Registration Filter Method from {@code FilterRegistration) that allows filters to be registered
            *  and configured with the specified context
            */
/*              
            FilterRegistration.Dynamic securityFilter = servletContext.addFilter(ProjectKeyValConsts.SECURITY_FILTER.getKey(), new DelegatingFilterProxy(ProjectKeyValConsts.SECURITY_FILTER.getValue()));
            securityFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, ProjectConsts.BASE_URL_MAPPING_PATTERN.getValue()); // where the filter will be applied
*/              
            // Add a Character Encoding Filter that specifies an encoding for mapped requests
            FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter());
            characterEncodingFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, ROOT_CONTEXT); // where the filter will be applied
            characterEncodingFilter.setInitParameter("encoding",  "UTF-8");
            characterEncodingFilter.setInitParameter("forceEncoding", Boolean.TRUE.toString());
            characterEncodingFilter.setAsyncSupported(true);
            
            servletContext.addListener(new ContextLoaderListener(context));
            servletContext.setInitParameter("defaultHtmlEscape", Boolean.TRUE.toString());
            
            DispatcherServlet servlet = new DispatcherServlet();
            
            // no explicit configuration reference here: everything is configured in the root container for simplicity
            servlet.setContextConfigLocation("");
            
            /* TMT From JEE 6 API Docs:
            * Registers the given servlet instance with this ServletContext under the given servletName.
            * The registered servlet may be further configured via the returned ServletRegistration object. 
            */

            ServletRegistration.Dynamic appServlet = servletContext.addServlet(APP_SERVLET, servlet);
            appServlet.setLoadOnStartup(1);
            appServlet.setAsyncSupported(true);
            
            Set<String> mappingConflicts = appServlet.addMapping("/");
            
            if (!mappingConflicts.isEmpty()) {
                    throw new IllegalStateException(String.format("The servlet named '%s' cannot be mapped to '/' under Tomcat versions <= 7.0.14", APP_SERVLET));
            }               
            
            // TMT
            servletContext.addListener(new Log4jConfigListener());
            
            System.out.println("Application inplemented on Spring Version: " + SpringVersion.getVersion());

    }
 
开发者ID:techtrip,项目名称:dynamicbeanloader,代码行数:55,代码来源:WebAppinitializer.java


示例5: registerListener

import org.springframework.web.util.Log4jConfigListener; //导入依赖的package包/类
private void registerListener(ServletContext servletContext) {
	servletContext.addListener(new Log4jConfigListener());
	servletContext.addListener(new RequestContextListener());
}
 
开发者ID:koen-serneels,项目名称:ws-proxy,代码行数:5,代码来源:WsProxyWebApplicationInitializer.java



注:本文中的org.springframework.web.util.Log4jConfigListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PowerVm类代码示例发布时间:2022-05-22
下一篇:
Java NMethod类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap