Skip to content

Latest commit

 

History

History
116 lines (84 loc) · 4.55 KB

README.md

File metadata and controls

116 lines (84 loc) · 4.55 KB

Pluggable Java web library for runtime logging level configuration

The goal of the project is to provide a logger configuration UI for changing logging levels directly from web interface.

License

Light Logging Configurer is released under version 2.0 of the Apache License.

Integration examples

Documentation & Support

Getting started

Light Logging Configurer is designed in such a way that it should integrate with your existing Java web applications with very little effort.

To install Light Logging Configurer alongside your application, simply add the required dependency, enable its WebApplicationInitializer using servlet context init parameters or register our ServletContextInitializer implementation if you're running Spring Boot app. The last step would be to adjust your logback configuration with "websocket-aware" appender.

Adding Light Logging Configurer to a Maven project

To add Light Logging Configurer to a Maven-based project, add the light-logging-configurer artifact to your compile-time dependencies:

<dependency>
  <groupId>org.lightadmin</groupId>
  <artifactId>light-logging-configurer</artifactId>
  <version>1.0.0.RC1</version>
</dependency>

Configuring Light Logging Configurer web module in Servlet 3.0 environment

To install Light Logging Configurer alongside your existing web application, you need to include the appropriate configuration to your WebApplicationInitializer.

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
  servletContext.setInitParameter(LIGHT_CONFIGURER_BASE_URL, "/logger");
  servletContext.setInitParameter(LIGHT_CONFIGURER_BACK_TO_SITE_URL, "http://lightadmin.org");
}

The equivalent of the above in a standard web.xml will also work identically to this configuration.

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0" metadata-complete="false">
         
  <context-param>
    <param-name>light:configurer:base-url</param-name>
    <param-value>/logger</param-value>
  </context-param>

  <context-param>
    <param-name>light:configurer:back-to-site-url</param-name>
    <param-value>http://lightadmin.org</param-value>
  </context-param>

</web-app>

Configuring Light Logging Configurer web module for Spring Boot application

To install Light Logging Configurer alongside your existing Spring Boot web application, you need to register ServletContextInitializer.

@Configuration
@EnableAutoConfiguration(exclude = {ThymeleafAutoConfiguration.class, SecurityAutoConfiguration.class})
public class Application extends SpringBootServletInitializer {
  
  public static void main(String[] args) throws Exception {
    SpringApplication.run(LightAdminBootApplication.class, args);
  }

  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(LightAdminBootApplication.class);
  }
    
  @Bean
  public ServletContextInitializer lightConfigurerServletContextInitializer() {
      return new LightConfigurerServletContextInitializer("/logger");
  }
}

Configuring Light Logging Configurer Logback appender

<configuration>
  <appender name="MessageSendingAppender" class="org.lightadmin.logging.configurer.logback.MessageSendingAppender"/>
  
  <logger name="org.lightadmin" level="INFO"/>
  
  <root level="INFO">
    <appender-ref ref="MessageSendingAppender"/>
  </root>
</configuration>

Screenshots

Main Screen